@@ -436,10 +436,13 @@ typeConstraintsForBinder val b@(NamedBinder name binder) = do
436 me <- fresh
436 me <- fresh
437 (cs, m) <- typeConstraintsForBinder val binder
437 (cs, m) <- typeConstraintsForBinder val binder
438 return (TypeConstraint me (TUnknown val) (BinderOrigin b) : cs, M.insert name me m)
438 return (TypeConstraint me (TUnknown val) (BinderOrigin b) : cs, M.insert name me m)
440+typeConstraintsForGuardedBinder :: M.Map Ident Int -> Int -> Binder -> Check ([TypeConstraint], M.Map Ident Int)
439−typeConstraintsForBinder val b@(GuardedBinder cond binder) = do
441+typeConstraintsForGuardedBinder m val b@(GuardedBinder cond binder) = do
440− (cs1, m) <- typeConstraintsForBinder val binder
442+ (cs1, m1) <- typeConstraintsForBinder val binder
441− (cs2, n) <- typeConstraints m cond
443+ (cs2, n) <- typeConstraints (m `M.union` m1) cond
442− return (TypeConstraint n Boolean (ValueOrigin cond) : cs1 ++ cs2, m)
444+ return (TypeConstraint n Boolean (ValueOrigin cond) : cs1 ++ cs2, m1)
445+typeConstraintsForGuardedBinder m val b = typeConstraintsForBinder val b >>= return
444constantBinder :: Binder -> Int -> Type -> Check ([TypeConstraint], M.Map Ident Int)
447constantBinder :: Binder -> Int -> Type -> Check ([TypeConstraint], M.Map Ident Int)
445constantBinder b val ty = return ([TypeConstraint val ty (BinderOrigin b)], M.empty)
448constantBinder 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
447typeConstraintsForBinders :: M.Map Ident Int -> Int -> Int -> [(Binder, Value)] -> Check [TypeConstraint]
450typeConstraintsForBinders :: M.Map Ident Int -> Int -> Int -> [(Binder, Value)] -> Check [TypeConstraint]
448typeConstraintsForBinders _ _ _ [] = return []
451typeConstraintsForBinders _ _ _ [] = return []
449typeConstraintsForBinders m nval ret ((binder, val):bs) = do
452typeConstraintsForBinders m nval ret ((binder, val):bs) = do
450− (cs1, m1) <- typeConstraintsForBinder nval binder
453+ (cs1, m1) <- typeConstraintsForGuardedBinder m nval binder
451 (cs2, n2) <- typeConstraints (m `M.union` m1) val
454 (cs2, n2) <- typeConstraints (m `M.union` m1) val
452 cs3 <- typeConstraintsForBinders m nval ret bs
455 cs3 <- typeConstraintsForBinders m nval ret bs
453 return (TypeConstraint n2 (TUnknown ret) (BinderOrigin binder) : cs1 ++ cs2 ++ cs3)
456 return (TypeConstraint n2 (TUnknown ret) (BinderOrigin binder) : cs1 ++ cs2 ++ cs3)