mirror of
https://github.com/vlang/v.git
synced 2025-09-17 11:26:17 -04:00
v fmt: fix extra space for anon struct (#16131)
This commit is contained in:
parent
c684dd8c9b
commit
2e8b9e3b92
@ -2133,7 +2133,7 @@ with a struct name.
|
|||||||
|
|
||||||
```v
|
```v
|
||||||
struct Book {
|
struct Book {
|
||||||
author struct {
|
author struct {
|
||||||
name string
|
name string
|
||||||
age int
|
age int
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ enum Selection {
|
|||||||
struct App {
|
struct App {
|
||||||
mut:
|
mut:
|
||||||
gg &gg.Context = unsafe { nil }
|
gg &gg.Context = unsafe { nil }
|
||||||
mouse struct {
|
mouse struct {
|
||||||
mut:
|
mut:
|
||||||
x f32
|
x f32
|
||||||
y f32
|
y f32
|
||||||
|
@ -2,7 +2,7 @@ module amod
|
|||||||
|
|
||||||
pub struct Foo {
|
pub struct Foo {
|
||||||
pub mut:
|
pub mut:
|
||||||
bar struct {
|
bar struct {
|
||||||
pub mut:
|
pub mut:
|
||||||
baz int
|
baz int
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,14 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl, is_anon bool) {
|
|||||||
f.write('pub ')
|
f.write('pub ')
|
||||||
}
|
}
|
||||||
if node.is_union {
|
if node.is_union {
|
||||||
f.write('union ')
|
f.write('union')
|
||||||
} else {
|
} else {
|
||||||
f.write('struct ')
|
f.write('struct')
|
||||||
}
|
}
|
||||||
f.write_language_prefix(node.language)
|
|
||||||
name := node.name.after('.') // strip prepended module
|
name := node.name.after('.') // strip prepended module
|
||||||
if !is_anon {
|
if !is_anon {
|
||||||
|
f.write(' ')
|
||||||
|
f.write_language_prefix(node.language)
|
||||||
f.write(name)
|
f.write(name)
|
||||||
}
|
}
|
||||||
f.write_generic_types(node.generic_types)
|
f.write_generic_types(node.generic_types)
|
||||||
|
@ -416,7 +416,7 @@ fn test_struct_update() {
|
|||||||
// Test anon structs
|
// Test anon structs
|
||||||
struct Book {
|
struct Book {
|
||||||
x Foo
|
x Foo
|
||||||
author struct {
|
author struct {
|
||||||
name string
|
name string
|
||||||
age int
|
age int
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user