aboutsummaryrefslogtreecommitdiff
path: root/src/Compiler.hs
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-08-18 07:28:56 +0100
committerJuan J. Martinez <jjm@usebox.net>2022-08-18 07:28:56 +0100
commitbdb014f3a088da82845642b9688c662bc7afa29f (patch)
tree85961c62015a1023e29d0cda3750232aa72bf530 /src/Compiler.hs
parent7dbd39e6e5d77b332f7b0b534eddddbd116e00b6 (diff)
downloadmicro-lang-hs-bdb014f3a088da82845642b9688c662bc7afa29f.tar.gz
micro-lang-hs-bdb014f3a088da82845642b9688c662bc7afa29f.zip
This words make the errors more readable
Diffstat (limited to 'src/Compiler.hs')
-rw-r--r--src/Compiler.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/Compiler.hs b/src/Compiler.hs
index c2dff73..06df1ae 100644
--- a/src/Compiler.hs
+++ b/src/Compiler.hs
@@ -54,7 +54,7 @@ typecheckCall args params
else
if all (\(a, b) -> a == b) $ zip t params -- compare types
then return $ Nothing -- all good!
- else return $ Just ("type mismatch in function call\n unexpected " ++ A.showList t ++ "\n expecting " ++ A.showList params)
+ else return $ Just ("type mismatch in function call\n found: " ++ A.showList t ++ "\n expected: " ++ A.showList params)
Nothing ->
-- there was an error in on argument
return $ Nothing
@@ -67,14 +67,14 @@ showMaybet (Just t) = show t
-- returning a string decribing an error or Nothing in case of a type match.
typecheckReturn :: Maybe A.Expr -> Maybe A.Type -> State CompState (Maybe String)
typecheckReturn Nothing Nothing = return $ Nothing
-typecheckReturn Nothing fret = return $ Just $ "invalid return value\n unexpected ()\n expecting " ++ showMaybet fret
+typecheckReturn Nothing fret = return $ Just $ "invalid return value\n found: ()\n expected: " ++ showMaybet fret
typecheckReturn (Just value) fret = do
r <- compile value
case r of
Right r ->
if r == fret
then return $ Nothing
- else return $ Just $ "invalid return value\n unexpected " ++ showMaybet r ++ "\n expecting " ++ showMaybet fret
+ else return $ Just $ "invalid return value\n found: " ++ showMaybet r ++ "\n expected: " ++ showMaybet fret
Left _ -> return $ Nothing -- error resolving return value
compile :: A.Expr -> State CompState CompResult