diff options
author | Juan J. Martinez <jjm@usebox.net> | 2022-08-14 08:55:12 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2022-08-14 08:55:12 +0100 |
commit | 079d5f51a63e409f83c5414fd848a90a0b8def62 (patch) | |
tree | 02c8494f1956146a54a0fa7598e7c2a4acbab9d2 /src | |
parent | dabbb47da06efaf1de526ccf12154c2d74afb35f (diff) | |
download | micro-lang-hs-079d5f51a63e409f83c5414fd848a90a0b8def62.tar.gz micro-lang-hs-079d5f51a63e409f83c5414fd848a90a0b8def62.zip |
Check arity
Diffstat (limited to 'src')
-rw-r--r-- | src/Compiler.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Compiler.hs b/src/Compiler.hs index d39a184..c373988 100644 --- a/src/Compiler.hs +++ b/src/Compiler.hs @@ -54,7 +54,13 @@ compile x = do (A.Call ident args pos) -> do r <- compile ident case r of - p@(Right (Just (A.FuncType _ _))) -> return $ p + p@(Right (Just (A.FuncType params _))) -> + if length args /= length params + then do + (ev, errs) <- get + put (ev, Error ("invalid number of arguments in function call") pos : errs) + return $ Right Nothing + else return $ p Right _ -> do (ev, errs) <- get put (ev, Error ("non callable value in function call") pos : errs) |