handle args count

This commit is contained in:
Mylloon 2022-12-10 16:11:37 +01:00
parent 5b915a88e8
commit c0c8880c56
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 23 additions and 0 deletions

View file

@ -25,6 +25,15 @@ let rec analyze_expr env ua t = function
(match Env.find c.func env with
| Func_t (ret_t, tl) ->
if ret_t != t then errt ret_t t c.pos;
if List.length tl != List.length c.args
then
raise
(SemanticsError
( Printf.sprintf
"Expected %d arguments but given %d"
(List.length tl)
(List.length c.args)
, c.pos ));
( Call
( c.func
, List.map2

View file

@ -0,0 +1,7 @@
int foo (int a) {
return a;
}
void main () {
foo(13, 12);
}

View file

@ -0,0 +1,7 @@
int foo (int a, int b) {
return a + b;
}
void main () {
foo(42);
}