From a884c2547196fe8f9d6135747ca3701f9b13e4de Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Sat, 11 Mar 2006 20:00:34 +0000 Subject: [PATCH] rejects functions without return statements --- Typecheck.hs | 3 +++ examples/typeerror-funcnoreturn | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 examples/typeerror-funcnoreturn 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; +} -- 2.39.2