mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix error for empty interface (#13764)
This commit is contained in:
parent
156efec278
commit
5237d1d446
@ -507,7 +507,7 @@ fn (mut g Gen) infix_expr_is_op(node ast.InfixExpr) {
|
||||
else { ast.Type(0) }
|
||||
}
|
||||
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
|
||||
} else if sym.kind == .sum_type {
|
||||
g.write('_typ $cmp_op ')
|
||||
|
14
vlib/v/tests/empty_interface_test.v
Normal file
14
vlib/v/tests/empty_interface_test.v
Normal file
@ -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
Block a user