summaryrefslogtreecommitdiff
path: root/dhall
diff options
context:
space:
mode:
Diffstat (limited to 'dhall')
-rw-r--r--dhall/src/semantics/resolve/resolve.rs12
-rw-r--r--dhall/tests/import/failure/alternativeEnv.txt7
-rw-r--r--dhall/tests/import/failure/alternativeEnvMissing.txt7
-rw-r--r--dhall/tests/import/failure/cycle.txt17
-rw-r--r--dhall/tests/import/failure/importBoundary.txt7
-rw-r--r--dhall/tests/import/failure/missing.txt7
-rw-r--r--dhall/tests/import/failure/referentiallyInsane.txt13
-rw-r--r--dhall/tests/import/failure/unit/EnvUnset.txt7
-rw-r--r--dhall/tests/import/failure/unit/EnvUnsetAsText.txt7
-rw-r--r--dhall/tests/import/failure/unit/FileMissing.dhall1
-rw-r--r--dhall/tests/import/failure/unit/FileMissing.txt6
11 files changed, 81 insertions, 10 deletions
diff --git a/dhall/src/semantics/resolve/resolve.rs b/dhall/src/semantics/resolve/resolve.rs
index 614ea22..68b899c 100644
--- a/dhall/src/semantics/resolve/resolve.rs
+++ b/dhall/src/semantics/resolve/resolve.rs
@@ -411,9 +411,17 @@ fn resolve_with_env(
// Resolve this import, making sure that recursive imports don't cycle back to the
// current one.
- let typed = env.with_cycle_detection(location.clone(), |env| {
+ let res = env.with_cycle_detection(location.clone(), |env| {
resolve_one_import(env, &import, location.clone(), span.clone())
- })?;
+ });
+ let typed = match res {
+ Ok(typed) => typed,
+ Err(e) => mkerr(
+ ErrorBuilder::new("error")
+ .span_err(span.clone(), e.to_string())
+ .format(),
+ )?,
+ };
// Add the resolved import to the caches
check_hash(&import, &typed, span)?;
diff --git a/dhall/tests/import/failure/alternativeEnv.txt b/dhall/tests/import/failure/alternativeEnv.txt
index 482b68c..bb862c3 100644
--- a/dhall/tests/import/failure/alternativeEnv.txt
+++ b/dhall/tests/import/failure/alternativeEnv.txt
@@ -1 +1,6 @@
-MissingEnvVar
+Type error: error: error
+ --> <current file>:1:45
+ |
+1 | env:UNSET1 as Text ? env:UNSET2 ? missing ? env:UNSET3
+ | ^^^^^^^^^^ MissingEnvVar
+ |
diff --git a/dhall/tests/import/failure/alternativeEnvMissing.txt b/dhall/tests/import/failure/alternativeEnvMissing.txt
index 4666330..1f26462 100644
--- a/dhall/tests/import/failure/alternativeEnvMissing.txt
+++ b/dhall/tests/import/failure/alternativeEnvMissing.txt
@@ -1 +1,6 @@
-Missing
+Type error: error: error
+ --> <current file>:1:13
+ |
+1 | env:UNSET ? missing
+ | ^^^^^^^ Missing
+ |
diff --git a/dhall/tests/import/failure/cycle.txt b/dhall/tests/import/failure/cycle.txt
index f5a1abf..899484b 100644
--- a/dhall/tests/import/failure/cycle.txt
+++ b/dhall/tests/import/failure/cycle.txt
@@ -1 +1,16 @@
-ImportCycle([Local("./dhall-lang/tests/import/data/cycle.dhall"), Local("./dhall-lang/tests/import/failure/cycle.dhall")], Local("./dhall-lang/tests/import/data/cycle.dhall"))
+Type error: error: error
+ --> <current file>:1:1
+ |
+1 | ../data/cycle.dhall
+ | ^^^^^^^^^^^^^^^^^^^ Type error: error: error
+ --> <current file>:1:1
+ |
+1 | ../failure/cycle.dhall
+ | ^^^^^^^^^^^^^^^^^^^^^^ Type error: error: error
+ --> <current file>:1:1
+ |
+1 | ../data/cycle.dhall
+ | ^^^^^^^^^^^^^^^^^^^ ImportCycle([Local("./dhall-lang/tests/import/data/cycle.dhall"), Local("./dhall-lang/tests/import/failure/cycle.dhall")], Local("./dhall-lang/tests/import/data/cycle.dhall"))
+ |
+ |
+ |
diff --git a/dhall/tests/import/failure/importBoundary.txt b/dhall/tests/import/failure/importBoundary.txt
index 56810e2..6ddb326 100644
--- a/dhall/tests/import/failure/importBoundary.txt
+++ b/dhall/tests/import/failure/importBoundary.txt
@@ -1,7 +1,12 @@
-Type error: error: unbound variable `x`
+Type error: error: error
+ --> <current file>:1:15
+ |
+1 | \(x: Bool) -> ../data/importBoundary.dhall
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Type error: error: unbound variable `x`
--> <current file>:1:1
|
...
3 | x
| ^ not found in this scope
|
+ |
diff --git a/dhall/tests/import/failure/missing.txt b/dhall/tests/import/failure/missing.txt
index 4666330..a15e9e0 100644
--- a/dhall/tests/import/failure/missing.txt
+++ b/dhall/tests/import/failure/missing.txt
@@ -1 +1,6 @@
-Missing
+Type error: error: error
+ --> <current file>:1:1
+ |
+1 | missing
+ | ^^^^^^^ Missing
+ |
diff --git a/dhall/tests/import/failure/referentiallyInsane.txt b/dhall/tests/import/failure/referentiallyInsane.txt
index 9b5fe91..1c6852a 100644
--- a/dhall/tests/import/failure/referentiallyInsane.txt
+++ b/dhall/tests/import/failure/referentiallyInsane.txt
@@ -1 +1,12 @@
-SanityCheck
+Type error: error: error
+ --> <current file>:6:1
+ |
+ 1 | {- The following remote import attempts to import an environment variable, which
+ 2 | must be disallowed by the referential sanity check
+ 3 |
+ 4 | One reason for doing this is to protect against remote imports exfiltrating
+...
+12 | -}
+13 | https://raw.githubusercontent.com/dhall-lang/dhall-lang/master/tests/import/data/referentiallyOpaque.dhall
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SanityCheck
+ |
diff --git a/dhall/tests/import/failure/unit/EnvUnset.txt b/dhall/tests/import/failure/unit/EnvUnset.txt
index 482b68c..12a8953 100644
--- a/dhall/tests/import/failure/unit/EnvUnset.txt
+++ b/dhall/tests/import/failure/unit/EnvUnset.txt
@@ -1 +1,6 @@
-MissingEnvVar
+Type error: error: error
+ --> <current file>:1:1
+ |
+1 | env:DHALL_TEST_UNSET
+ | ^^^^^^^^^^^^^^^^^^^^ MissingEnvVar
+ |
diff --git a/dhall/tests/import/failure/unit/EnvUnsetAsText.txt b/dhall/tests/import/failure/unit/EnvUnsetAsText.txt
index 482b68c..6571560 100644
--- a/dhall/tests/import/failure/unit/EnvUnsetAsText.txt
+++ b/dhall/tests/import/failure/unit/EnvUnsetAsText.txt
@@ -1 +1,6 @@
-MissingEnvVar
+Type error: error: error
+ --> <current file>:1:1
+ |
+1 | env:DHALL_TEST_UNSET as Text
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ MissingEnvVar
+ |
diff --git a/dhall/tests/import/failure/unit/FileMissing.dhall b/dhall/tests/import/failure/unit/FileMissing.dhall
new file mode 100644
index 0000000..cba1bcc
--- /dev/null
+++ b/dhall/tests/import/failure/unit/FileMissing.dhall
@@ -0,0 +1 @@
+./not-a-file.dhall
diff --git a/dhall/tests/import/failure/unit/FileMissing.txt b/dhall/tests/import/failure/unit/FileMissing.txt
new file mode 100644
index 0000000..351909d
--- /dev/null
+++ b/dhall/tests/import/failure/unit/FileMissing.txt
@@ -0,0 +1,6 @@
+Type error: error: error
+ --> <current file>:1:1
+ |
+1 | ./not-a-file.dhall
+ | ^^^^^^^^^^^^^^^^^^ No such file or directory (os error 2)
+ |