From 079d5f51a63e409f83c5414fd848a90a0b8def62 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sun, 14 Aug 2022 08:55:12 +0100 Subject: Check arity --- src/Compiler.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/Compiler.hs') 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) -- cgit v1.2.3