@@ -436,10 +436,13 @@ typeConstraintsForBinder val b@(NamedBinder name binder) = do
436436 me <- fresh
437437 (cs, m) <- typeConstraintsForBinder val binder
438438 return (TypeConstraint me (TUnknown val) (BinderOrigin b) : cs, M.insert name me m)
439−typeConstraintsForBinder val b@(GuardedBinder cond binder) = do
440− (cs1, m) <- typeConstraintsForBinder val binder
441− (cs2, n) <- typeConstraints m cond
442− return (TypeConstraint n Boolean (ValueOrigin cond) : cs1 ++ cs2, m)
439+
440+typeConstraintsForGuardedBinder :: M.Map Ident Int -> Int -> Binder -> Check ([TypeConstraint], M.Map Ident Int)
441+typeConstraintsForGuardedBinder m val b@(GuardedBinder cond binder) = do
442+ (cs1, m1) <- typeConstraintsForBinder val binder
443+ (cs2, n) <- typeConstraints (m `M.union` m1) cond
444+ return (TypeConstraint n Boolean (ValueOrigin cond) : cs1 ++ cs2, m1)
445+typeConstraintsForGuardedBinder m val b = typeConstraintsForBinder val b >>= return
443446
444447constantBinder :: Binder -> Int -> Type -> Check ([TypeConstraint], M.Map Ident Int)
445448constantBinder b val ty = return ([TypeConstraint val ty (BinderOrigin b)], M.empty)
@@ -447,7 +450,7 @@ constantBinder b val ty = return ([TypeConstraint val ty (BinderOrigin b)], M.em
447450typeConstraintsForBinders :: M.Map Ident Int -> Int -> Int -> [(Binder, Value)] -> Check [TypeConstraint]
448451typeConstraintsForBinders _ _ _ [] = return []
449452typeConstraintsForBinders m nval ret ((binder, val):bs) = do
450− (cs1, m1) <- typeConstraintsForBinder nval binder
453+ (cs1, m1) <- typeConstraintsForGuardedBinder m nval binder
451454 (cs2, n2) <- typeConstraints (m `M.union` m1) val
452455 cs3 <- typeConstraintsForBinders m nval ret bs
453456 return (TypeConstraint n2 (TUnknown ret) (BinderOrigin binder) : cs1 ++ cs2 ++ cs3)