From 92ea98da2f89348c3dfdc7d49594a4d876d06ba2 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 18 Mar 2019 05:27:17 +0100 Subject: Split List literal between empty and non-empty --- dhall/src/typecheck.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'dhall/src/typecheck.rs') 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> = 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()))?; -- cgit v1.2.3