summaryrefslogtreecommitdiff
path: root/check.hs
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-02-01 13:06:20 +0100
committertomsmeding <tom.smeding@gmail.com>2017-02-01 13:06:20 +0100
commit238d16ef9e183275ab00a72ed61a280501b9bcad (patch)
treeae57db7b78ba4c9c20c57971b8fb3e5540a30233 /check.hs
parent00a56284a8649d041af079fe466f94034f2ee1fb (diff)
More operators and less function pointers
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 ++ "'")