cgen: minor array_init fix

pull/5357/head
yuyi 2020-06-12 08:19:48 +08:00 committed by GitHub
parent ff1437fc5a
commit 47ffedc5de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 5 deletions

View File

@ -4345,12 +4345,10 @@ fn (mut g Gen) array_init(it ast.ArrayInit) {
g.write('sizeof($elem_type_str), ')
if is_default_array {
g.write('_val_$it.pos.pos)')
} else if it.has_default || (it.has_len && it.elem_type == table.string_type) {
g.write('&_val_$it.pos.pos)')
} else {
if it.has_default || (it.has_len && it.elem_type == table.string_type) {
g.write('&_val_$it.pos.pos)')
} else {
g.write('0)')
}
g.write('0)')
}
return
}