diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-02-01 13:06:20 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-02-01 13:06:20 +0100 |
commit | 238d16ef9e183275ab00a72ed61a280501b9bcad (patch) | |
tree | ae57db7b78ba4c9c20c57971b8fb3e5540a30233 /check.hs | |
parent | 00a56284a8649d041af079fe466f94034f2ee1fb (diff) |
More operators and less function pointers
Diffstat (limited to 'check.hs')
-rw-r--r-- | check.hs | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -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 ++ "'") |