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

gen: correct indirection difference between reciever and object (#8903)

This commit is contained in:
Emily Hudson 2021-02-22 12:41:25 -06:00 committed by GitHub
parent d78c9476e9
commit 79edff5c6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -647,7 +647,21 @@ fn (mut g Gen) method_call(node ast.CallExpr) {
if !node.left_type.has_flag(.shared_f) {
g.write('/*rec*/*')
}
} else if !is_range_slice && node.from_embed_type == 0 && node.name != 'str' {
diff := node.left_type.nr_muls() - node.receiver_type.nr_muls()
if diff < 0 {
// TODO
// g.write('&')
} else if diff > 0 {
g.write('/*diff=$diff*/')
g.write([]byte{len: diff, init: `*`}.bytestr())
}
}
// if node.left_type.idx() != node.receiver_type.idx() {
// println('${g.typ(node.left_type)} ${g.typ(node.receiver_type)}')
// }
if g.is_autofree && node.free_receiver && !g.inside_lambda && !g.is_builtin_mod {
// The receiver expression needs to be freed, use the temp var.
fn_name := node.name.replace('.', '_')