1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

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

This commit is contained in:
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

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 {