aboutsummaryrefslogtreecommitdiff
path: root/src/Compiler.hs
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-08-14 08:55:12 +0100
committerJuan J. Martinez <jjm@usebox.net>2022-08-14 08:55:12 +0100
commit079d5f51a63e409f83c5414fd848a90a0b8def62 (patch)
tree02c8494f1956146a54a0fa7598e7c2a4acbab9d2 /src/Compiler.hs
parentdabbb47da06efaf1de526ccf12154c2d74afb35f (diff)
downloadmicro-lang-hs-079d5f51a63e409f83c5414fd848a90a0b8def62.tar.gz
micro-lang-hs-079d5f51a63e409f83c5414fd848a90a0b8def62.zip
Check arity
Diffstat (limited to 'src/Compiler.hs')
-rw-r--r--src/Compiler.hs8
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)