From 70af1a47bce9e6c8282d6e53cf82aeda9aab10de Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 30 Jan 2020 22:08:57 +0000 Subject: Tweak ConstantClosure --- dhall/src/semantics/tck/typecheck.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'dhall/src/semantics/tck') diff --git a/dhall/src/semantics/tck/typecheck.rs b/dhall/src/semantics/tck/typecheck.rs index e3f57c2..20076cd 100644 --- a/dhall/src/semantics/tck/typecheck.rs +++ b/dhall/src/semantics/tck/typecheck.rs @@ -200,20 +200,22 @@ fn type_one_layer( match scrut_nf.kind() { ValueKind::UnionType(kts) => match kts.get(x) { // Constructor has type T -> < x: T, ... > - Some(Some(ty)) => Value::from_kind_and_type( - ValueKind::PiClosure { - binder: Binder::new(x.clone()), - annot: ty.clone(), - closure: Closure::new_constant( - env.as_nzenv(), - scrut.clone(), - ), - }, - type_of_function( + Some(Some(ty)) => { + let pi_ty = type_of_function( ty.get_type()?, scrut.get_type()?, - )?, - ), + )?; + Value::from_kind_and_type( + ValueKind::PiClosure { + binder: Binder::new(x.clone()), + annot: ty.clone(), + closure: Closure::new_constant( + scrut_nf, + ), + }, + pi_ty, + ) + } Some(None) => scrut_nf, None => return mkerr("MissingUnionField"), }, -- cgit v1.2.3