From 938d3ffad7cd3b76692c81ae983c3ce82b10c2d1 Mon Sep 17 00:00:00 2001 From: Andrii Riabushenko Date: Wed, 5 Dec 2018 19:29:14 +0000 Subject: [PATCH] add test --- compiler/destroyer.nim | 33 ++++++++++++++++------------ tests/destructor/tmove_objconstr.nim | 11 +++++++++- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/compiler/destroyer.nim b/compiler/destroyer.nim index a26a4d379..352b4aaad 100644 --- a/compiler/destroyer.nim +++ b/compiler/destroyer.nim @@ -413,7 +413,7 @@ proc passCopyToSink(n: PNode; c: var Con): PNode = proc pArg(arg: PNode; c: var Con; isSink: bool): PNode = template pArgIfTyped(arg_part: PNode): PNode = # typ is nil if we are in if/case expr branch with noreturn - if arg_part.typ == nil: copyTree(arg_part) + if arg_part.typ == nil: p(arg_part, c) else: pArg(arg_part, c, isSink) if isSink: @@ -478,7 +478,7 @@ proc pArg(arg: PNode; c: var Con; isSink: bool): PNode = proc moveOrCopy(dest, ri: PNode; c: var Con): PNode = template moveOrCopyIfTyped(ri_part: PNode): PNode = # typ is nil if we are in if/case expr branch with noreturn - if ri_part.typ == nil: copyTree(ri_part) + if ri_part.typ == nil: p(ri_part, c) else: moveOrCopy(dest, ri_part, c) case ri.kind @@ -537,29 +537,32 @@ proc moveOrCopy(dest, ri: PNode; c: var Con): PNode = result.add branch of nkBracket: # array constructor + result = genSink(c, dest.typ, dest, ri) let ri2 = copyTree(ri) for i in 0.. 1: newMySeq(3, 1.0) else: newMySeq(0, 0.0)] +var seqOfSeq2 = @[newMySeq(2, 5.0), newMySeq(3, 1.0)] \ No newline at end of file