From: Mart Lubbers Date: Thu, 14 Apr 2016 07:06:27 +0000 (+0200) Subject: hi X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=ebcd007897feb48e987110c2ddbaea8ddcbef109;p=cc1516.git hi --- diff --git a/sem.icl b/sem.icl index 06200b1..f3d28c2 100644 --- a/sem.icl +++ b/sem.icl @@ -70,7 +70,8 @@ semFunDecl fd=:(FunDecl p f args mt vds stmts) = inferReturnType :: [Stmt] -> Env Type inferReturnType [] = pure VoidType -inferReturnType [ReturnStmt (Just t):rest] = typeExpr t +inferReturnType [ReturnStmt (Just t):rest] = typeExpr t + >>= \tx->inferReturnType rest >>= \ty->unify tx ty inferReturnType [ReturnStmt _:rest] = pure VoidType inferReturnType [_:rest] = inferReturnType rest @@ -200,6 +201,8 @@ instance unify Type where unify (ListType t1) (ListType t2) = unify t1 t2 >>| (pure $ ListType t1) unify (ta1 ->> ta2) (tb1 ->> tb2) = unify ta1 tb1 >>= \ta-> unify ta2 tb2 >>= \tb-> pure (ta ->> tb) + unify VoidType t = pure t + unify t VoidType = pure t unify VoidType VoidType = pure VoidType unify t1 t2 = liftT $ Left $ UnifyError zero t1 t2