v.gen.c: fix calling pointer receiver on function return result (#10866)

pull/10870/head
Uwe Krüger 2021-07-20 07:30:07 +02:00 committed by GitHub
parent eed4f50d8c
commit de39bba7bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -762,7 +762,12 @@ fn (mut g Gen) method_call(node ast.CallExpr) {
// Add `&` automatically.
// TODO same logic in call_args()
if !is_range_slice {
g.write('&')
if !node.left.is_lvalue() {
g.write('ADDR($rec_cc_type, ')
has_cast = true
} else {
g.write('&')
}
}
} else if !node.receiver_type.is_ptr() && node.left_type.is_ptr() && node.name != 'str'
&& node.from_embed_type == 0 {