Skip to content

Commit

Permalink
checker: fix compiler crashes when passing an extra decompose paramet…
Browse files Browse the repository at this point in the history
…er to a function(fix: 18995) (#18996)
  • Loading branch information
shove70 committed Jul 29, 2023
1 parent a61a2fd commit 8586f18
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vlib/v/checker/fn.v
Expand Up @@ -2304,7 +2304,7 @@ fn (mut c Checker) check_expected_arg_count(mut node ast.CallExpr, f &ast.Fn) !
has_decompose := node.args.filter(it.expr is ast.ArrayDecompose).len > 0
if has_decompose {
// if call(...args) is present
min_required_params = nr_args
min_required_params = nr_args - 1
}
}
if min_required_params < 0 {
Expand Down
@@ -0,0 +1,6 @@
vlib/v/checker/tests/fn_array_decompose_arg_mismatch_err_c.vv:2:6: error: expected 0 arguments, but got 1
1 | fn main() {
2 | foo(...args)
| ~~~~~~~
3 | }
4 |
6 changes: 6 additions & 0 deletions vlib/v/checker/tests/fn_array_decompose_arg_mismatch_err_c.vv
@@ -0,0 +1,6 @@
fn main() {
foo(...args)
}

fn foo() {
}

0 comments on commit 8586f18

Please sign in to comment.