diff options
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 ++ "'") |