From fe007f9b160f9d685df14851d7d239461d6b6b29 Mon Sep 17 00:00:00 2001 From: spaceface Date: Mon, 15 Feb 2021 16:35:31 +0100 Subject: [PATCH] gen: fix type_name for sumtype/interface pointers (#8769) --- vlib/v/gen/c/fn.v | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vlib/v/gen/c/fn.v b/vlib/v/gen/c/fn.v index 3d6737a104..2bd2435172 100644 --- a/vlib/v/gen/c/fn.v +++ b/vlib/v/gen/c/fn.v @@ -534,13 +534,15 @@ fn (mut g Gen) method_call(node ast.CallExpr) { if left_sym.kind == .sum_type && node.name == 'type_name' { g.write('tos3( /* $left_sym.name */ v_typeof_sumtype_${typ_sym.cname}( (') g.expr(node.left) - g.write(').typ ))') + dot := if node.left_type.is_ptr() { '->' } else { '.' } + g.write(')${dot}typ ))') return } if left_sym.kind == .interface_ && node.name == 'type_name' { g.write('tos3( /* $left_sym.name */ v_typeof_interface_${typ_sym.cname}( (') g.expr(node.left) - g.write(')._interface_idx ))') + dot := if node.left_type.is_ptr() { '->' } else { '.' } + g.write(')${dot}_interface_idx ))') return } if node.name == 'str' {