mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: fix formating fn with variadic argument (#15900)
This commit is contained in:
parent
66249b8c45
commit
be6741195d
3
vlib/v/fmt/tests/fn_with_variadic_arg_expected.vv
Normal file
3
vlib/v/fmt/tests/fn_with_variadic_arg_expected.vv
Normal file
@ -0,0 +1,3 @@
|
||||
fn abc(a ...int) {}
|
||||
|
||||
fn main() {}
|
3
vlib/v/fmt/tests/fn_with_variadic_arg_input.vv
Normal file
3
vlib/v/fmt/tests/fn_with_variadic_arg_input.vv
Normal file
@ -0,0 +1,3 @@
|
||||
fn abc(a ...int, ) {}
|
||||
|
||||
fn main() {}
|
@ -971,7 +971,7 @@ fn (mut p Parser) fn_args() ([]ast.Param, bool, bool) {
|
||||
type_pos: type_pos[i]
|
||||
}
|
||||
// if typ.typ.kind == .variadic && p.tok.kind == .comma {
|
||||
if is_variadic && p.tok.kind == .comma {
|
||||
if is_variadic && p.tok.kind == .comma && p.peek_tok.kind != .rpar {
|
||||
p.error_with_pos('cannot use ...(variadic) with non-final parameter $arg_name',
|
||||
arg_pos[i])
|
||||
return []ast.Param{}, false, false
|
||||
|
Loading…
Reference in New Issue
Block a user