summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadrieril2020-11-28 02:20:38 +0000
committerGitHub2020-11-28 02:20:38 +0000
commit52eb91195981ccca0232ce6f0cf0a5c82224e3f4 (patch)
tree87d73a718e2d39353b512d00879a9d6df3ceeef4
parent8be3891b1e30f61b1f38b96e1ed200f367066032 (diff)
parentc231c18917a69e87ac4339627620b323d7d9552b (diff)
Merge pull request #202 from basile-henry/if-type
If can return a type
Diffstat (limited to '')
-rw-r--r--.gitignore1
m---------dhall-lang0
-rw-r--r--dhall/src/operations/typecheck.rs4
-rw-r--r--dhall/tests/type-inference/failure/unit/IfBranchesNotTermTypeOrKind.txt4
-rw-r--r--dhall/tests/type-inference/failure/unit/IfBranchesNotType.txt6
5 files changed, 5 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index eb5a316..bd32e74 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
+.direnv
target
diff --git a/dhall-lang b/dhall-lang
-Subproject 8e0674eb419876e81d9e2218ddefc503a85fd58
+Subproject b2344e922a3cebc4f5b055abe52d3ec50be6eab
diff --git a/dhall/src/operations/typecheck.rs b/dhall/src/operations/typecheck.rs
index 3016fea..bc0e864 100644
--- a/dhall/src/operations/typecheck.rs
+++ b/dhall/src/operations/typecheck.rs
@@ -350,8 +350,8 @@ pub fn typecheck_operation(
if *x.ty().kind() != NirKind::from_builtin(Builtin::Bool) {
return span_err("InvalidPredicate");
}
- if y.ty().ty().as_const() != Some(Const::Type) {
- return span_err("IfBranchMustBeTerm");
+ if y.ty().ty().as_const().is_none() {
+ return span_err("IfBranchMustBeTermTypeOrKind");
}
if y.ty() != z.ty() {
return span_err("IfBranchMismatch");
diff --git a/dhall/tests/type-inference/failure/unit/IfBranchesNotTermTypeOrKind.txt b/dhall/tests/type-inference/failure/unit/IfBranchesNotTermTypeOrKind.txt
index 8b46d1f..4023128 100644
--- a/dhall/tests/type-inference/failure/unit/IfBranchesNotTermTypeOrKind.txt
+++ b/dhall/tests/type-inference/failure/unit/IfBranchesNotTermTypeOrKind.txt
@@ -1,6 +1,6 @@
-Type error: error: IfBranchMustBeTerm
+Type error: error: IfBranchMustBeTermTypeOrKind
--> <current file>:1:1
|
1 | if True then Kind else Kind
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IfBranchMustBeTerm
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IfBranchMustBeTermTypeOrKind
|
diff --git a/dhall/tests/type-inference/failure/unit/IfBranchesNotType.txt b/dhall/tests/type-inference/failure/unit/IfBranchesNotType.txt
deleted file mode 100644
index 4c9ec28..0000000
--- a/dhall/tests/type-inference/failure/unit/IfBranchesNotType.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-Type error: error: IfBranchMustBeTerm
- --> <current file>:1:1
- |
-1 | if True then Type else Type
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IfBranchMustBeTerm
- |