summaryrefslogtreecommitdiff
path: root/dhall/src/typecheck.rs
diff options
context:
space:
mode:
authorNadrieril2019-03-18 05:27:17 +0100
committerNadrieril2019-03-18 05:27:17 +0100
commit92ea98da2f89348c3dfdc7d49594a4d876d06ba2 (patch)
tree90de90c45a361538d50d875fa5543fbd4b6ad9d8 /dhall/src/typecheck.rs
parent5c33165e95eb264fa9d305c097b183f6622aad03 (diff)
Split List literal between empty and non-empty
Diffstat (limited to '')
-rw-r--r--dhall/src/typecheck.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/dhall/src/typecheck.rs b/dhall/src/typecheck.rs
index 26ab360..387327a 100644
--- a/dhall/src/typecheck.rs
+++ b/dhall/src/typecheck.rs
@@ -351,15 +351,16 @@ where
}
return Ok(ty);
}
- ListLit(t, xs) => {
+ EmptyListLit(t) => {
+ let s = normalized_type_with(ctx, t.clone())?;
+ ensure_is_type(s, InvalidListType(t.clone()))?;
+ let t = normalize(Rc::clone(t));
+ return Ok(dhall_expr!(List t));
+ }
+ NEListLit(xs) => {
let mut iter = xs.iter().enumerate();
- let t: Rc<Expr<_, _>> = match t {
- Some(t) => t.clone(),
- None => {
- let (_, first_x) = iter.next().unwrap();
- type_with(ctx, first_x.clone())?
- }
- };
+ let (_, first_x) = iter.next().unwrap();
+ let t = type_with(ctx, first_x.clone())?;
let s = normalized_type_with(ctx, t.clone())?;
ensure_is_type(s, InvalidListType(t.clone()))?;