diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-07-08 14:47:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-08 14:47:14 +0200 |
commit | 06d776a5828d429f62c3189a99161604d50f9b96 (patch) | |
tree | ceacd12e5c00b8573ddd4d23e58a0f927c30a6ab /compiler | |
parent | cb1ecbf95620bffd559610b70f99c6f16963ac5c (diff) | |
download | Nim-06d776a5828d429f62c3189a99161604d50f9b96.tar.gz |
fixes #14900, this time for real, maybe (#14934)
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/injectdestructors.nim | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim index 67d61525e..b5e1db169 100644 --- a/compiler/injectdestructors.nim +++ b/compiler/injectdestructors.nim @@ -134,7 +134,7 @@ proc toTree(c: var Con; s: var Scope; ret: PNode; flags: set[ToTreeFlag]): PNode var r = PNode(nil) if isExpr: result = newNodeIT(nkStmtListExpr, ret.info, ret.typ) - if ret.kind == nkStmtListExpr: + if ret.kind in nkCallKinds + {nkStmtListExpr}: r = getTemp(c, s, ret.typ, ret.info) else: result = newNodeI(nkStmtList, ret.info) @@ -155,7 +155,13 @@ proc toTree(c: var Con; s: var Scope; ret: PNode; flags: set[ToTreeFlag]): PNode result.add newTryFinally(ret, finSection) else: if r != nil: - result.add newTree(nkFastAsgn, r, ret) + if ret.kind == nkStmtListExpr: + # simplify it a bit further by merging the nkStmtListExprs + let last = ret.len - 1 + for i in 0 ..< last: result.add ret[i] + result.add newTree(nkFastAsgn, r, ret[last]) + else: + result.add newTree(nkFastAsgn, r, ret) else: result.add ret for m in s.wasMoved: result.add m |