]> ruin.nu Git - proglang.git/blobdiff - Typecheck.hs
rejects functions without return statements
[proglang.git] / Typecheck.hs
index e2aa3d7182d61eef64d28b462efb2f3d9efde328..5c70ccf02c04118b27f297e854d887be05c58a13 100644 (file)
@@ -117,6 +117,9 @@ typeCheckFunction (Func t i d s) = do
        state <- get
        modify (\s -> s{variables=[empty], function=i})
        mapM (\(Decl t i) -> addVariable i t) d
+       case last s of
+               (SReturn _) -> return ()
+               _ -> fail $ "Function "++show i++" doesn't end with return statement"
        mapM typeCheckStm s
        put state