mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
fix
This commit is contained in:
parent
efe611ed99
commit
28c4542315
3 changed files with 24 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
|
|
6
vlib/v/checker/tests/multi_return_arg_missing_err.out
Normal file
6
vlib/v/checker/tests/multi_return_arg_missing_err.out
Normal 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 | }
|
10
vlib/v/checker/tests/multi_return_arg_missing_err.vv
Normal file
10
vlib/v/checker/tests/multi_return_arg_missing_err.vv
Normal file
|
@ -0,0 +1,10 @@
|
|||
fn t(a int, b int) {
|
||||
}
|
||||
|
||||
fn g() (int, int) {
|
||||
return 1, 1
|
||||
}
|
||||
|
||||
fn main() {
|
||||
t(1, g())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue