diff options
author | Juan J. Martinez <jjm@usebox.net> | 2022-09-04 12:10:34 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2022-09-04 12:10:34 +0100 |
commit | 99db32319623ac384ec1ae7735c9a899710d451b (patch) | |
tree | 5b46f68ebd385e99d93ac5529815c402159c00ff /src | |
parent | f5730b3fda45b1cd3efe1ce276419aeaa3e7915b (diff) | |
download | micro-lang-hs-99db32319623ac384ec1ae7735c9a899710d451b.tar.gz micro-lang-hs-99db32319623ac384ec1ae7735c9a899710d451b.zip |
Resolving the value may add errors to state
In this way we preserve them (like in "return").
Diffstat (limited to 'src')
-rw-r--r-- | src/Compiler.hs | 9 |
1 files changed, 4 insertions, 5 deletions
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 |