1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

gen: fix type_name for sumtype/interface pointers (#8769)

This commit is contained in:
spaceface 2021-02-15 16:35:31 +01:00 committed by GitHub
parent 4213851e22
commit fe007f9b16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -534,13 +534,15 @@ fn (mut g Gen) method_call(node ast.CallExpr) {
if left_sym.kind == .sum_type && node.name == 'type_name' { if left_sym.kind == .sum_type && node.name == 'type_name' {
g.write('tos3( /* $left_sym.name */ v_typeof_sumtype_${typ_sym.cname}( (') g.write('tos3( /* $left_sym.name */ v_typeof_sumtype_${typ_sym.cname}( (')
g.expr(node.left) g.expr(node.left)
g.write(').typ ))') dot := if node.left_type.is_ptr() { '->' } else { '.' }
g.write(')${dot}typ ))')
return return
} }
if left_sym.kind == .interface_ && node.name == 'type_name' { if left_sym.kind == .interface_ && node.name == 'type_name' {
g.write('tos3( /* $left_sym.name */ v_typeof_interface_${typ_sym.cname}( (') g.write('tos3( /* $left_sym.name */ v_typeof_interface_${typ_sym.cname}( (')
g.expr(node.left) g.expr(node.left)
g.write(')._interface_idx ))') dot := if node.left_type.is_ptr() { '->' } else { '.' }
g.write(')${dot}_interface_idx ))')
return return
} }
if node.name == 'str' { if node.name == 'str' {