summaryrefslogtreecommitdiff
path: root/dhall
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dhall/src/error/mod.rs17
-rw-r--r--dhall/tests/type-errors/hurkensParadox.txt7
-rw-r--r--dhall/tests/type-errors/unit/FunctionApplicationArgumentNotMatch.txt12
-rw-r--r--dhall/tests/type-errors/unit/ListLiteralEmptyNotType.txt7
-rw-r--r--dhall/tests/type-errors/unit/MergeHandlerNotMatchAlternativeType.txt12
-rw-r--r--dhall/tests/type-errors/unit/NaturalSubtractNotNatural.txt7
6 files changed, 59 insertions, 3 deletions
diff --git a/dhall/src/error/mod.rs b/dhall/src/error/mod.rs
index 4d59cbb..e4baea0 100644
--- a/dhall/src/error/mod.rs
+++ b/dhall/src/error/mod.rs
@@ -111,9 +111,20 @@ impl std::fmt::Display for TypeError {
v.span().error("Type error: Invalid function output")
}
NotAFunction(v) => v.span().error("Type error: Not a function"),
- TypeMismatch(v, _, _) => v
- .span()
- .error("Type error: Wrong type of function argument"),
+ TypeMismatch(x, y, z) => {
+ x.span()
+ .error("Type error: Wrong type of function argument")
+ + "\n"
+ + &z.span().error(format!(
+ "This argument has type {:?}",
+ z.get_type().unwrap()
+ ))
+ + "\n"
+ + &y.span().error(format!(
+ "But the function expected an argument of type {:?}",
+ y
+ ))
+ }
_ => "Type error: Unhandled error".to_string(),
};
write!(f, "{}", msg)
diff --git a/dhall/tests/type-errors/hurkensParadox.txt b/dhall/tests/type-errors/hurkensParadox.txt
index 69428b8..870388d 100644
--- a/dhall/tests/type-errors/hurkensParadox.txt
+++ b/dhall/tests/type-errors/hurkensParadox.txt
@@ -1 +1,8 @@
[unknown location] Type error: Wrong type of function argument
+[unknown location] This argument has type Sort
+ --> 5:21
+ |
+5 | in let pow = λ(X : Kind) → X → Type␊
+ | ^--^
+ |
+ = But the function expected an argument of type Kind
diff --git a/dhall/tests/type-errors/unit/FunctionApplicationArgumentNotMatch.txt b/dhall/tests/type-errors/unit/FunctionApplicationArgumentNotMatch.txt
index 69428b8..d3b1f50 100644
--- a/dhall/tests/type-errors/unit/FunctionApplicationArgumentNotMatch.txt
+++ b/dhall/tests/type-errors/unit/FunctionApplicationArgumentNotMatch.txt
@@ -1 +1,13 @@
[unknown location] Type error: Wrong type of function argument
+ --> 1:22
+ |
+1 | (λ(_ : Natural) → _) True␊
+ | ^--^
+ |
+ = This argument has type Value@WHNF { value: AppliedBuiltin(Bool, []), type: Type }
+ --> 1:8
+ |
+1 | (λ(_ : Natural) → _) True␊
+ | ^-----^
+ |
+ = But the function expected an argument of type Value@WHNF { value: AppliedBuiltin(Natural, []), type: Type }
diff --git a/dhall/tests/type-errors/unit/ListLiteralEmptyNotType.txt b/dhall/tests/type-errors/unit/ListLiteralEmptyNotType.txt
index bc5cc40..e075521 100644
--- a/dhall/tests/type-errors/unit/ListLiteralEmptyNotType.txt
+++ b/dhall/tests/type-errors/unit/ListLiteralEmptyNotType.txt
@@ -4,3 +4,10 @@
| ^--^
|
= Type error: Wrong type of function argument
+ --> 1:11
+ |
+1 | [] : List Type␊
+ | ^--^
+ |
+ = This argument has type Kind
+[unknown location] But the function expected an argument of type Type
diff --git a/dhall/tests/type-errors/unit/MergeHandlerNotMatchAlternativeType.txt b/dhall/tests/type-errors/unit/MergeHandlerNotMatchAlternativeType.txt
index 69428b8..3f6c6a6 100644
--- a/dhall/tests/type-errors/unit/MergeHandlerNotMatchAlternativeType.txt
+++ b/dhall/tests/type-errors/unit/MergeHandlerNotMatchAlternativeType.txt
@@ -1 +1,13 @@
[unknown location] Type error: Wrong type of function argument
+ --> 1:38
+ |
+1 | merge { x = λ(_ : Bool) → _ } (< x : Natural >.x 1)␊
+ | ^-----^
+ |
+ = This argument has type Type
+ --> 1:19
+ |
+1 | merge { x = λ(_ : Bool) → _ } (< x : Natural >.x 1)␊
+ | ^--^
+ |
+ = But the function expected an argument of type Value@WHNF { value: AppliedBuiltin(Bool, []), type: Type }
diff --git a/dhall/tests/type-errors/unit/NaturalSubtractNotNatural.txt b/dhall/tests/type-errors/unit/NaturalSubtractNotNatural.txt
index fd906bf..02a9c45 100644
--- a/dhall/tests/type-errors/unit/NaturalSubtractNotNatural.txt
+++ b/dhall/tests/type-errors/unit/NaturalSubtractNotNatural.txt
@@ -4,3 +4,10 @@
| ^--------------^
|
= Type error: Wrong type of function argument
+ --> 1:18
+ |
+1 | Natural/subtract True True␊
+ | ^--^
+ |
+ = This argument has type Value@WHNF { value: AppliedBuiltin(Bool, []), type: Type }
+[unknown location] But the function expected an argument of type Value@WHNF { value: AppliedBuiltin(Natural, []), type: Type }