summaryrefslogtreecommitdiff
path: root/dhall
diff options
context:
space:
mode:
authorNadrieril2020-12-07 19:58:05 +0000
committerNadrieril2020-12-08 20:25:20 +0000
commit70508b6a6cff9cd1bb6383be939914edf1fc653a (patch)
tree6401e207346036fa013ddb5b3f00a51786cee834 /dhall
parent109dcf894e759bce1c28f9ae94f3fdaa6e08feb5 (diff)
fix: fix import ordering issue
Diffstat (limited to 'dhall')
-rw-r--r--dhall/src/semantics/resolve/resolve.rs14
-rw-r--r--dhall/tests/import/success/unit/DontCacheIfHashA.dhall2
-rw-r--r--dhall/tests/import/success/unit/DontCacheIfHashB.dhall1
3 files changed, 10 insertions, 7 deletions
diff --git a/dhall/src/semantics/resolve/resolve.rs b/dhall/src/semantics/resolve/resolve.rs
index 116e1a5..2dc1ffe 100644
--- a/dhall/src/semantics/resolve/resolve.rs
+++ b/dhall/src/semantics/resolve/resolve.rs
@@ -381,13 +381,6 @@ fn fetch_import<'cx>(
// If the import is in the in-memory cache, or the hash is in the on-disk cache, return
// the cached contents.
- if let Some(res_id) = env.get_from_mem_cache(&location) {
- // The same location may be used with different or no hashes. Thus we need to check
- // the hashes every time.
- env.check_hash(import_id, res_id)?;
- env.write_to_disk_cache(&import.hash, res_id);
- return Ok(res_id);
- }
if let Some(typed) = env.get_from_disk_cache(&import.hash) {
// No need to check the hash, it was checked before reading the file.
// We also don't write to the in-memory cache, because the location might be completely
@@ -397,6 +390,13 @@ fn fetch_import<'cx>(
let res_id = cx.push_import_result(typed);
return Ok(res_id);
}
+ if let Some(res_id) = env.get_from_mem_cache(&location) {
+ // The same location may be used with different or no hashes. Thus we need to check
+ // the hashes every time.
+ env.check_hash(import_id, res_id)?;
+ env.write_to_disk_cache(&import.hash, res_id);
+ return Ok(res_id);
+ }
// Resolve this import, making sure that recursive imports don't cycle back to the
// current one.
diff --git a/dhall/tests/import/success/unit/DontCacheIfHashA.dhall b/dhall/tests/import/success/unit/DontCacheIfHashA.dhall
new file mode 100644
index 0000000..ed5ffad
--- /dev/null
+++ b/dhall/tests/import/success/unit/DontCacheIfHashA.dhall
@@ -0,0 +1,2 @@
+let x = ../../data/simple.dhall
+in ../../data/simple.dhall sha256:3871180b87ecaba8b53fffb2a8b52d3fce98098fab09a6f759358b9e8042eedc
diff --git a/dhall/tests/import/success/unit/DontCacheIfHashB.dhall b/dhall/tests/import/success/unit/DontCacheIfHashB.dhall
new file mode 100644
index 0000000..660a1cc
--- /dev/null
+++ b/dhall/tests/import/success/unit/DontCacheIfHashB.dhall
@@ -0,0 +1 @@
+λ(_ : Type) → λ(_ : Optional _) → merge { `None` = True, `Some` = λ(_ : _@1) → False } _