aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-08-14 17:38:02 +0100
committerJuan J. Martinez <jjm@usebox.net>2022-08-14 17:38:02 +0100
commit0118394558cef840c47952c1dd997a235c279ada (patch)
tree82e4e57195535bac79114cd35f948dd219b61aaa /src
parent9fbb168d465a15e0134addacf14323993ef0e579 (diff)
downloadmicro-lang-hs-0118394558cef840c47952c1dd997a235c279ada.tar.gz
micro-lang-hs-0118394558cef840c47952c1dd997a235c279ada.zip
Missing case
Diffstat (limited to 'src')
-rw-r--r--src/Compiler.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Compiler.hs b/src/Compiler.hs
index 62be364..602490e 100644
--- a/src/Compiler.hs
+++ b/src/Compiler.hs
@@ -59,10 +59,15 @@ typecheckCall args params
-- there was an error in on argument
return $ Nothing
+showMaybet :: Maybe A.Type -> String
+showMaybet Nothing = "()"
+showMaybet (Just t) = show t
+
-- | @typecheckReturn value fret@ resolves @value@ and compares it with @fret@,
-- 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 (Just value) fret = do
r <- compile value
case r of
@@ -71,10 +76,6 @@ typecheckReturn (Just value) fret = do
then return $ Nothing
else return $ Just $ "invalid return value:\n unexpected " ++ showMaybet r ++ "\n expecting " ++ showMaybet fret
Left _ -> return $ Nothing -- error resolving return value
- where
- showMaybet :: Maybe A.Type -> String
- showMaybet Nothing = "()"
- showMaybet (Just t) = show t
compile :: A.Expr -> State CompState CompResult
compile x = do