From 711ad900153aedb7b35896c0705c932972edded2 Mon Sep 17 00:00:00 2001 From: Basile Henry Date: Fri, 27 Nov 2020 23:08:14 +0100 Subject: If can return a type --- dhall/src/operations/typecheck.rs | 4 ++-- .../type-inference/failure/unit/IfBranchesNotTermTypeOrKind.txt | 4 ++-- dhall/tests/type-inference/failure/unit/IfBranchesNotType.txt | 6 ------ 3 files changed, 4 insertions(+), 10 deletions(-) delete mode 100644 dhall/tests/type-inference/failure/unit/IfBranchesNotType.txt 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 --> :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 - --> :1:1 - | -1 | if True then Type else Type - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IfBranchMustBeTerm - | -- cgit v1.2.3 From d617c6109926dc4f5aa37f99833654f2db810462 Mon Sep 17 00:00:00 2001 From: Basile Henry Date: Fri, 27 Nov 2020 23:06:28 +0100 Subject: Update dhall-lang --- dhall-lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dhall-lang b/dhall-lang index 8e0674e..b2344e9 160000 --- a/dhall-lang +++ b/dhall-lang @@ -1 +1 @@ -Subproject commit 8e0674eb419876e81d9e2218ddefc503a85fd580 +Subproject commit b2344e922a3cebc4f5b055abe52d3ec50be6eab1 -- cgit v1.2.3 From c231c18917a69e87ac4339627620b323d7d9552b Mon Sep 17 00:00:00 2001 From: Basile Henry Date: Fri, 27 Nov 2020 23:08:36 +0100 Subject: Add .direnv to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index eb5a316..bd32e74 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +.direnv target -- cgit v1.2.3