aboutsummaryrefslogtreecommitdiff
path: root/src/Compiler.hs
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-08-17 22:30:42 +0100
committerJuan J. Martinez <jjm@usebox.net>2022-08-17 22:30:42 +0100
commit593d78ebd7e2d10c609a4e5e363ed89386ab27cf (patch)
treeaf46824bc65ae1fdc4dd25a9e6c395a92ba9479f /src/Compiler.hs
parentacbe62d01a76e5adb29ff479cca01588c65cf561 (diff)
downloadmicro-lang-hs-593d78ebd7e2d10c609a4e5e363ed89386ab27cf.tar.gz
micro-lang-hs-593d78ebd7e2d10c609a4e5e363ed89386ab27cf.zip
More sensible error types
Diffstat (limited to 'src/Compiler.hs')
-rw-r--r--src/Compiler.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Compiler.hs b/src/Compiler.hs
index 413a041..c2dff73 100644
--- a/src/Compiler.hs
+++ b/src/Compiler.hs
@@ -114,24 +114,24 @@ compile x = do
Right (Just (A.FuncType params rtyp)) -> do
r <- typecheckCall args params
case r of
- Just err -> addError $ TypeError err pos
+ Just err -> addError $ Error TypeError err pos
Nothing -> return $ Right rtyp
- Right _ -> addError $ Error "non callable value in function call" pos
+ Right _ -> addError $ Error GenericError "non callable value in function call" pos
_ -> return $ Right Nothing
(A.Return value pos) -> do
(ev, errs) <- get
case getSyml ev "$fn$" of
- Nothing -> addError $ UnexpectedReturn "return without function call" pos
+ Nothing -> addError $ Error UnexpectedReturn "return without function call" pos
Just (_, A.FuncType _ rtyp, _) -> do
r <- typecheckReturn value rtyp
case r of
- Just err -> addError $ TypeError err pos
+ Just err -> addError $ Error TypeError err pos
Nothing -> return $ Right rtyp
(A.Var ident pos) -> do
(ev, errs) <- get
case getSym ev ident of
Just (_, t, _) -> return $ Right $ Just t
- Nothing -> addError $ Error ("undefined variable \"" ++ ident ++ "\"") pos
+ Nothing -> addError $ Error GenericError ("undefined variable \"" ++ ident ++ "\"") pos
compileAll :: [A.Expr] -> State CompState CompResult
compileAll (x : xs) = do