From: Michael Andreen Date: Sat, 11 Mar 2006 20:00:34 +0000 (+0000) Subject: rejects functions without return statements X-Git-Url: https://ruin.nu/git/?p=proglang.git;a=commitdiff_plain;h=a884c2547196fe8f9d6135747ca3701f9b13e4de rejects functions without return statements --- diff --git a/Typecheck.hs b/Typecheck.hs index e2aa3d7..5c70ccf 100644 --- a/Typecheck.hs +++ b/Typecheck.hs @@ -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 diff --git a/examples/typeerror-funcnoreturn b/examples/typeerror-funcnoreturn new file mode 100644 index 0000000..1fb75eb --- /dev/null +++ b/examples/typeerror-funcnoreturn @@ -0,0 +1,3 @@ +int a(){ + int a; +}