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 {