Skip to content

Commit 8586f18

Browse files
authored
checker: fix compiler crashes when passing an extra decompose parameter to a function(fix: 18995) (#18996)
1 parent a61a2fd commit 8586f18

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

vlib/v/checker/fn.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2304,7 +2304,7 @@ fn (mut c Checker) check_expected_arg_count(mut node ast.CallExpr, f &ast.Fn) !
23042304
has_decompose := node.args.filter(it.expr is ast.ArrayDecompose).len > 0
23052305
if has_decompose {
23062306
// if call(...args) is present
2307-
min_required_params = nr_args
2307+
min_required_params = nr_args - 1
23082308
}
23092309
}
23102310
if min_required_params < 0 {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
vlib/v/checker/tests/fn_array_decompose_arg_mismatch_err_c.vv:2:6: error: expected 0 arguments, but got 1
2+
1 | fn main() {
3+
2 | foo(...args)
4+
| ~~~~~~~
5+
3 | }
6+
4 |
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn main() {
2+
foo(...args)
3+
}
4+
5+
fn foo() {
6+
}

0 commit comments

Comments
 (0)