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
|
||||
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
Block a user