mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix zero init bug of embedded structs (#7567)
This commit is contained in:
parent
60086a06ac
commit
7507403118
@ -4460,6 +4460,9 @@ fn (mut g Gen) struct_init(struct_init ast.StructInit) {
|
|||||||
// TODO handle/require optionals in inits
|
// TODO handle/require optionals in inits
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if field.typ in info.embeds {
|
||||||
|
continue
|
||||||
|
}
|
||||||
g.zero_struct_field(field)
|
g.zero_struct_field(field)
|
||||||
if is_multiline {
|
if is_multiline {
|
||||||
g.writeln(',')
|
g.writeln(',')
|
||||||
|
@ -26,6 +26,11 @@ fn test_default_value() {
|
|||||||
b := Bar{Foo: Foo{}}
|
b := Bar{Foo: Foo{}}
|
||||||
assert b.y == 5
|
assert b.y == 5
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_default_value_without_init() {
|
||||||
|
b := Bar{}
|
||||||
|
assert b.y == 5
|
||||||
|
}
|
||||||
/* TODO
|
/* TODO
|
||||||
fn test_initialize() {
|
fn test_initialize() {
|
||||||
b := Bar{x: 1, y: 2}
|
b := Bar{x: 1, y: 2}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user