From 311b5e818829bdfcce3da1b5ac141325d2ef4c25 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 22 Nov 2020 13:45:12 +0100 Subject: [PATCH] autofree: string.clone() fix --- vlib/v/gen/cgen.v | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 8bb14c16ba..abefafe27a 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -2911,12 +2911,13 @@ fn (mut g Gen) infix_expr(node ast.InfixExpr) { if elem_sym.kind == .interface_ && node.right_type != info.elem_type { g.interface_call(node.right_type, info.elem_type) } - // if g.pref.autofree && info.elem_type == table.string_type { - if info.elem_type == table.string_type { + // if g.pref.autofree + needs_clone := info.elem_type == table.string_type && !g.is_builtin_mod + if needs_clone { g.write('string_clone(') } g.expr_with_cast(node.right, node.right_type, info.elem_type) - if info.elem_type == table.string_type { + if needs_clone { g.write(')') } if is_interface {