From 79edff5c6c758624079ffd4f6938f31d0933c25d Mon Sep 17 00:00:00 2001 From: Emily Hudson Date: Mon, 22 Feb 2021 12:41:25 -0600 Subject: [PATCH] gen: correct indirection difference between reciever and object (#8903) --- vlib/v/gen/c/fn.v | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vlib/v/gen/c/fn.v b/vlib/v/gen/c/fn.v index fc1bca944c..c1fb82d453 100644 --- a/vlib/v/gen/c/fn.v +++ b/vlib/v/gen/c/fn.v @@ -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('.', '_')