From 593d78ebd7e2d10c609a4e5e363ed89386ab27cf Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Wed, 17 Aug 2022 22:30:42 +0100 Subject: More sensible error types --- src/Compiler.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Compiler.hs') 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 -- cgit v1.2.3