1
0
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:
yuyi 2022-09-28 15:55:36 +08:00 committed by GitHub
parent 66249b8c45
commit be6741195d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View File

@ -0,0 +1,3 @@
fn abc(a ...int) {}
fn main() {}

View File

@ -0,0 +1,3 @@
fn abc(a ...int, ) {}
fn main() {}

View File

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