mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix struct initialization
This commit is contained in:
parent
bb587c27a8
commit
abd0686043
@ -1902,7 +1902,8 @@ fn (g mut Gen) struct_init(it ast.StructInit) {
|
||||
// info := g.table.get_type_symbol(it.typ).info as table.Struct
|
||||
// println(info.fields.len)
|
||||
styp := g.typ(it.typ)
|
||||
if g.is_amp {
|
||||
is_amp := g.is_amp
|
||||
if is_amp {
|
||||
g.out.go_back(1) // delete the & already generated in `prefix_expr()
|
||||
g.write('($styp*)memdup(&($styp){')
|
||||
}
|
||||
@ -1943,7 +1944,7 @@ fn (g mut Gen) struct_init(it ast.StructInit) {
|
||||
g.write('0')
|
||||
}
|
||||
g.write('}')
|
||||
if g.is_amp {
|
||||
if is_amp {
|
||||
g.write(', sizeof($styp))')
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user