From 44b9ea4a7596f7c98bdd7dd6df49f38d88c6ffea Mon Sep 17 00:00:00 2001 From: joe-conigliaro Date: Tue, 8 Dec 2020 16:08:10 +1100 Subject: [PATCH] cgen: selector expr / method call on sumtype pointer #7191 --- vlib/v/gen/cgen.v | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index b433a77a90..02209f40b5 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -2611,7 +2611,8 @@ fn (mut g Gen) expr(node ast.Expr) { g.write('(*') cast_sym := g.table.get_type_symbol(typ) if i != 0 { - sum_type_deref_field += ').' + dot := if field.typ.is_ptr() { '->' } else { '.' } + sum_type_deref_field += ')$dot' } if mut cast_sym.info is table.Aggregate { agg_sym := g.table.get_type_symbol(cast_sym.info.types[g.aggregate_type_idx]) @@ -3439,11 +3440,12 @@ fn (mut g Gen) ident(node ast.Ident) { if i == 0 { g.write(name) } + dot := if v.typ.is_ptr() { '->' } else { '.' } if mut cast_sym.info is table.Aggregate { sym := g.table.get_type_symbol(cast_sym.info.types[g.aggregate_type_idx]) - g.write('._$sym.cname') + g.write('${dot}_$sym.cname') } else { - g.write('._$cast_sym.cname') + g.write('${dot}_$cast_sym.cname') } g.write(')') }