1
0
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:
yuyi 2022-03-19 04:41:06 +08:00 committed by GitHub
parent 156efec278
commit 5237d1d446
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -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 ')

View 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'
}