From 60d8f688a0c66759bdb7645c9dd4c232bc433c9f Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Mon, 15 Aug 2022 12:11:10 +0100 Subject: Unify error reporting --- src/Compiler.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Compiler.hs') diff --git a/src/Compiler.hs b/src/Compiler.hs index 0d90143..49af369 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 unexpected " ++ A.showList t ++ "\n expecting " ++ 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 unexpected ()\n expecting " ++ 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 unexpected " ++ showMaybet r ++ "\n expecting " ++ showMaybet fret Left _ -> return $ Nothing -- error resolving return value compile :: A.Expr -> State CompState CompResult -- cgit v1.2.3