From 0e55534c6eb0d0003412953f17a30d679481c7fa Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 20 Oct 2020 16:27:39 +0300 Subject: [PATCH] cgen: fix spurious autoref bug, for struct init of a &C.type field, with a byteptr value --- vlib/v/gen/cgen.v | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index f700df02ae..7a75461bd6 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -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)