cgen: fix error for empty interface (#13764)
parent
156efec278
commit
5237d1d446
|
@ -507,7 +507,7 @@ fn (mut g Gen) infix_expr_is_op(node ast.InfixExpr) {
|
||||||
else { ast.Type(0) }
|
else { ast.Type(0) }
|
||||||
}
|
}
|
||||||
sub_sym := g.table.sym(sub_type)
|
sub_sym := g.table.sym(sub_type)
|
||||||
g.write('_${c_name(sym.name)}_${c_name(sub_sym.name)}_index')
|
g.write('_${sym.cname}_${sub_sym.cname}_index')
|
||||||
return
|
return
|
||||||
} else if sym.kind == .sum_type {
|
} else if sym.kind == .sum_type {
|
||||||
g.write('_typ $cmp_op ')
|
g.write('_typ $cmp_op ')
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
interface Any {}
|
||||||
|
|
||||||
|
fn print_out(x Any) string {
|
||||||
|
if x is string {
|
||||||
|
println(x)
|
||||||
|
return '$x'
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_empty_interface() {
|
||||||
|
ret := print_out('12345')
|
||||||
|
assert ret == '&12345'
|
||||||
|
}
|
Loading…
Reference in New Issue