This commit is contained in:
Felipe Pena 2025-08-27 08:30:55 -03:00
parent efe611ed99
commit 28c4542315
3 changed files with 24 additions and 2 deletions

View file

@ -1684,15 +1684,21 @@ fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool) ast.
}
}
out: for n in 0 .. arg_typ_sym.info.types.len {
num_arg := n + 1
curr_arg := arg_typs[n]
multi_param := if func.is_variadic && i >= func.params.len - 1 {
func.params.last()
} else {
func.params[n + i]
if func.params.len - 1 < num_arg {
c.error('missing argument ${i + num_arg} on `${fn_name}` to receive ${c.table.type_to_str(arg_typ)}',
call_arg.pos)
continue out
}
func.params[num_arg]
}
c.check_expected_call_arg(curr_arg, c.unwrap_generic(multi_param.typ),
node.language, call_arg) or {
c.error('${err.msg()} in argument ${i + n + 1} to `${fn_name}` from ${c.table.type_to_str(arg_typ)}',
c.error('${err.msg()} in argument ${i + num_arg} to `${fn_name}` from ${c.table.type_to_str(arg_typ)}',
call_arg.pos)
continue out
}

View file

@ -0,0 +1,6 @@
vlib/v/checker/tests/multi_return_arg_missing_err.vv:9:7: error: missing argument 3 on `t` to receive (int, int)
7 |
8 | fn main() {
9 | t(1, g())
| ~~~
10 | }

View file

@ -0,0 +1,10 @@
fn t(a int, b int) {
}
fn g() (int, int) {
return 1, 1
}
fn main() {
t(1, g())
}