cgen: fix zero init bug of embedded structs (#7567)
parent
60086a06ac
commit
7507403118
|
@ -4460,6 +4460,9 @@ fn (mut g Gen) struct_init(struct_init ast.StructInit) {
|
|||
// TODO handle/require optionals in inits
|
||||
continue
|
||||
}
|
||||
if field.typ in info.embeds {
|
||||
continue
|
||||
}
|
||||
g.zero_struct_field(field)
|
||||
if is_multiline {
|
||||
g.writeln(',')
|
||||
|
|
|
@ -26,6 +26,11 @@ fn test_default_value() {
|
|||
b := Bar{Foo: Foo{}}
|
||||
assert b.y == 5
|
||||
}
|
||||
|
||||
fn test_default_value_without_init() {
|
||||
b := Bar{}
|
||||
assert b.y == 5
|
||||
}
|
||||
/* TODO
|
||||
fn test_initialize() {
|
||||
b := Bar{x: 1, y: 2}
|
||||
|
|
Loading…
Reference in New Issue