@@ -3448,8 +3448,11 @@ fn (mut g Gen) selector_expr(node ast.SelectorExpr) {
34483448 g.checker_bug ('unexpected SelectorExpr.expr_type = 0' , node.pos)
34493449 }
34503450
3451+ sym := g.table.sym (g.unwrap_generic (node.expr_type))
3452+ field_name := if sym.language == .v { c_name (node.field_name) } else { node.field_name }
3453+
34513454 if node.or_block.kind != .absent && ! g.is_assign_lhs && g.table.sym (node.typ).kind != .chan {
3452- is_ptr := g.table. sym (g. unwrap_generic (node.expr_type)) .kind in [.interface_, .sum_type]
3455+ is_ptr := sym.kind in [.interface_, .sum_type]
34533456 stmt_str := g.go_before_stmt (0 ).trim_space ()
34543457 styp := g.typ (node.typ)
34553458 g.empty_line = true
@@ -3459,7 +3462,7 @@ fn (mut g Gen) selector_expr(node ast.SelectorExpr) {
34593462 g.write ('*(' )
34603463 }
34613464 g.expr (node.expr)
3462- g.write ('.${node. field_name} ' )
3465+ g.write ('.${field_name} ' )
34633466 if is_ptr {
34643467 g.write (')' )
34653468 }
@@ -3472,7 +3475,6 @@ fn (mut g Gen) selector_expr(node ast.SelectorExpr) {
34723475 return
34733476 }
34743477
3475- sym := g.table.sym (g.unwrap_generic (node.expr_type))
34763478 // if node expr is a root ident and an optional
34773479 mut is_opt_or_res := node.expr is ast.Ident
34783480 && (node.expr_type.has_flag (.option) || node.expr_type.has_flag (.result))
@@ -3640,7 +3642,6 @@ fn (mut g Gen) selector_expr(node ast.SelectorExpr) {
36403642 if node.expr_type == 0 {
36413643 verror ('cgen: SelectorExpr | expr_type: 0 | it.expr: `${node.expr} ` | field: `${node.field_name} ` | file: ${g.file.path} | line: ${node.pos.line_nr} ' )
36423644 }
3643- field_name := if sym.language == .v { c_name (node.field_name) } else { node.field_name }
36443645 g.write (field_name)
36453646 if sum_type_deref_field != '' {
36463647 g.write ('${sum_type_dot}${sum_type_deref_field} )' )
0 commit comments