cgen: return interface fix
parent
1ca7a607d3
commit
905f844b16
|
@ -2314,11 +2314,12 @@ fn (mut g Gen) return_statement(node ast.Return) {
|
||||||
g.writeln(' }, sizeof($styp));')
|
g.writeln(' }, sizeof($styp));')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if sym.kind == .interface_ {
|
cast_interface := sym.kind == .interface_ && node.types[0] != g.fn_decl.return_type
|
||||||
|
if cast_interface {
|
||||||
g.interface_call(node.types[0], g.fn_decl.return_type)
|
g.interface_call(node.types[0], g.fn_decl.return_type)
|
||||||
}
|
}
|
||||||
g.expr_with_cast(node.exprs[0], node.types[0], g.fn_decl.return_type)
|
g.expr_with_cast(node.exprs[0], node.types[0], g.fn_decl.return_type)
|
||||||
if sym.kind == .interface_ {
|
if cast_interface {
|
||||||
g.write(')')
|
g.write(')')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,3 +243,7 @@ fn new_animal() Animal {
|
||||||
dog := Dog{}
|
dog := Dog{}
|
||||||
return dog
|
return dog
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn new_animal2() Animal {
|
||||||
|
return new_animal()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue