1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: fix compiler crashes when passing an extra decompose parameter to a function(fix: 18995) (#18996)

This commit is contained in:
shove 2023-07-29 20:38:39 +08:00 committed by GitHub
parent a61a2fd328
commit 8586f18383
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -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 has_decompose := node.args.filter(it.expr is ast.ArrayDecompose).len > 0
if has_decompose { if has_decompose {
// if call(...args) is present // if call(...args) is present
min_required_params = nr_args min_required_params = nr_args - 1
} }
} }
if min_required_params < 0 { if min_required_params < 0 {

View File

@ -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 |

View File

@ -0,0 +1,6 @@
fn main() {
foo(...args)
}
fn foo() {
}