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

vfmt: fix extra whitspace in fn type decl with type-only args (#6888)

This commit is contained in:
Lukas Neubert 2020-11-20 15:00:40 +01:00 committed by GitHub
parent 30ddb89e3c
commit 5d76e85a23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View File

@ -534,10 +534,11 @@ pub fn (mut f Fmt) type_decl(node ast.TypeDecl) {
should_add_type := true || is_last_arg || fn_info.params[i + 1].typ != arg.typ ||
(fn_info.is_variadic && i == fn_info.params.len - 2)
if should_add_type {
ns := if arg.name == '' { '' } else { ' ' }
if fn_info.is_variadic && is_last_arg {
f.write(' ...' + s)
f.write(ns + '...' + s)
} else {
f.write(' ' + s)
f.write(ns + s)
}
}
if !is_last_arg {

View File

@ -24,3 +24,5 @@ type TwoSameArgs = fn (i int, j int) string // And a comment
type VarArgs = fn (s ...string) int
type NOVarArgs = fn (i int, s ...string) f64
type NoNameArgs = fn (int, string, ...string)

View File

@ -33,3 +33,5 @@ type VarArgs = fn
(s ...string) int
type NOVarArgs = fn(i int, s ...string) f64
type NoNameArgs = fn( int, string , ...string)