From 99db32319623ac384ec1ae7735c9a899710d451b Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sun, 4 Sep 2022 12:10:34 +0100 Subject: Resolving the value may add errors to state In this way we preserve them (like in "return"). --- src/Compiler.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Compiler.hs b/src/Compiler.hs index c59c2e3..ce31299 100644 --- a/src/Compiler.hs +++ b/src/Compiler.hs @@ -158,12 +158,11 @@ compile x = do if not (definedType typ) then Error UndefinedType ("undefined type in variable declaration \"" ++ ident ++ "\"") pos : errs else errs - vt <- typecheckVal val $ Just typ - errs <- case vt of - Just err -> return $ Error TypeError err pos : errs - Nothing -> return $ errs put (ev, errs) - return $ Right $ Just typ + vt <- typecheckVal val $ Just typ + case vt of + Just err -> addError $ Error TypeError err pos + Nothing -> return $ Right $ Just typ (A.Return value pos) -> do (ev, errs) <- get case getSyml ev "$fn$" of -- cgit v1.2.3