summaryrefslogtreecommitdiff
path: root/check.hs
diff options
context:
space:
mode:
Diffstat (limited to 'check.hs')
-rw-r--r--check.hs2
1 files changed, 2 insertions, 0 deletions
diff --git a/check.hs b/check.hs
index b6a660b..9b8ffc6 100644
--- a/check.hs
+++ b/check.hs
@@ -80,6 +80,7 @@ typeCheck (Program decls) = Program <$> mapM (goD topLevelNames) decls
goD names (DecFunction frt name args body) = do
newbody <- goB frt (foldr (\(t,n) m -> Map.insert n t m) names args) body
return $ DecFunction frt name args newbody
+ goD _ (DecVariable (TypeFunc _ _) _ _) = Left $ "Cannot declare global variable with function type"
goD _ dec = return dec
goB :: Type -- function return type
@@ -94,6 +95,7 @@ typeCheck (Program decls) = Program <$> mapM (goD topLevelNames) decls
goS :: Type -- function return type
-> Map.Map Name Type -> Statement -> Error (Map.Map Name Type, Statement)
+ goS _ _ (StVarDeclaration (TypeFunc _ _) _ _) = Left $ "Cannot declare variable with function type"
goS _ names st@(StVarDeclaration t n Nothing) = do
maybe (return (Map.insert n t names, st))
(const $ Left $ "Duplicate variable '" ++ n ++ "'")