From 837298f26e07bb264a6b6f0286cbb811553b0477 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 30 Jan 2020 14:49:17 +0000 Subject: Increase encapsulation for Closures --- dhall/src/semantics/tck/typecheck.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'dhall/src/semantics/tck') diff --git a/dhall/src/semantics/tck/typecheck.rs b/dhall/src/semantics/tck/typecheck.rs index 0c5e779..bc1c87f 100644 --- a/dhall/src/semantics/tck/typecheck.rs +++ b/dhall/src/semantics/tck/typecheck.rs @@ -6,7 +6,7 @@ use crate::error::{TypeError, TypeMessage}; use crate::semantics::phase::normalize::merge_maps; use crate::semantics::phase::Normalized; use crate::semantics::{ - type_of_builtin, Binder, BuiltinClosure, Closure, NzVar, TyEnv, TyExpr, + type_of_builtin, Binder, BuiltinClosure, Closure, TyEnv, TyExpr, TyExprKind, Type, Value, ValueKind, }; use crate::syntax::{ @@ -48,7 +48,7 @@ fn type_of_function(src: Type, tgt: Type) -> Result { Ok(Value::from_const(function_check(ks, kt))) } -fn mkerr(x: impl ToString) -> Result { +fn mkerr(x: S) -> Result { Err(TypeError::new(TypeMessage::Custom(x.to_string()))) } @@ -452,9 +452,9 @@ fn type_one_layer( return mkerr("MergeHandlerTypeMismatch"); } - let v = NzVar::fresh(); - // TODO: handle case where variable is used in closure - closure.apply_var(v) + closure.remove_binder().or_else(|()| { + mkerr("MergeReturnTypeIsDependent") + })? } _ => return mkerr("NotAFunction"), } -- cgit v1.2.3