autofree: string.clone() fix

pull/6913/head
Alexander Medvednikov 2020-11-22 13:45:12 +01:00
parent 65005fdae8
commit 311b5e8188
1 changed files with 4 additions and 3 deletions

View File

@ -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 {