cgen: fix spurious autoref bug, for struct init of a &C.type field, with a byteptr value

pull/6656/head
Delyan Angelov 2020-10-20 16:27:39 +03:00
parent 74ebce6b1f
commit 0e55534c6e
1 changed files with 4 additions and 2 deletions

View File

@ -3850,7 +3850,8 @@ fn (mut g Gen) struct_init(struct_init ast.StructInit) {
}
}
if !cloned {
if field.expected_type.is_ptr() && !field.typ.is_ptr() && !field.typ.is_number() {
if field.expected_type.is_ptr() && !(field.typ.is_ptr() || field.typ.is_pointer()) &&
!field.typ.is_number() {
g.write('/* autoref */&')
}
g.expr_with_cast(field.expr, field.typ, field.expected_type)
@ -3889,7 +3890,8 @@ fn (mut g Gen) struct_init(struct_init ast.StructInit) {
}
}
if !cloned {
if sfield.expected_type.is_ptr() && !sfield.typ.is_ptr() && !sfield.typ.is_number() {
if sfield.expected_type.is_ptr() && !(sfield.typ.is_ptr() || sfield.typ.is_pointer()) &&
!sfield.typ.is_number() {
g.write('/* autoref */&')
}
g.expr_with_cast(sfield.expr, sfield.typ, sfield.expected_type)