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

fmt: fix bug that vfmt removes emmbeded struct in struct decl (#8775)

This commit is contained in:
zakuro 2021-02-16 20:45:56 +09:00 committed by GitHub
parent 94429c8fd8
commit 51c286df5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 1 deletions

View File

@ -643,7 +643,7 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl) {
f.write(gtypes)
f.write('>')
}
if node.fields.len == 0 && node.pos.line_nr == node.pos.last_line {
if node.fields.len == 0 && node.embeds.len == 0 && node.pos.line_nr == node.pos.last_line {
f.writeln(' {}\n')
return
}

View File

@ -10,3 +10,8 @@ struct Bar {
y int
z string
}
struct Baz {
Foo
Test
}

View File

@ -25,6 +25,10 @@ pub mut:
pub_mut_field string
}
struct Bar {
Foo
}
fn new_user() User {
return User{
name: 'Serious Sam'

View File

@ -25,6 +25,8 @@ struct Foo {
pub_mut_field string
}
struct Bar { Foo }
fn new_user()
User
{