diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-10-08 14:17:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-08 14:17:27 +0200 |
commit | 1e9d83efb0e59d3a71bf3b077808b96f29c5e529 (patch) | |
tree | 93cba6edc7437f3307b230922b4237e8e3510192 | |
parent | 4d91cc79508e27c35ea9b733cb0e778b1d7fdad1 (diff) | |
download | Nim-1e9d83efb0e59d3a71bf3b077808b96f29c5e529.tar.gz |
fixes #15512 (#15521)
-rw-r--r-- | compiler/injectdestructors.nim | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim index 28f2c93f1..bec8b49f4 100644 --- a/compiler/injectdestructors.nim +++ b/compiler/injectdestructors.nim @@ -593,6 +593,18 @@ template handleNestedTempl(n, processCall: untyped, willProduceStmt = false) = result.add processScope(c, bodyScope, bodyResult) dec c.inLoop + of nkParForStmt: + inc c.inLoop + result = shallowCopy(n) + let last = n.len-1 + for i in 0..<last-1: + result[i] = n[i] + result[last-1] = p(n[last-1], c, s, normal) + var bodyScope = nestedScope(s) + let bodyResult = p(n[last], c, bodyScope, normal) + result[last] = processScope(c, bodyScope, bodyResult) + dec c.inLoop + of nkBlockStmt, nkBlockExpr: result = copyNode(n) result.add n[0] @@ -668,7 +680,7 @@ proc pRaiseStmt(n: PNode, c: var Con; s: var Scope): PNode = proc p(n: PNode; c: var Con; s: var Scope; mode: ProcessMode): PNode = if n.kind in {nkStmtList, nkStmtListExpr, nkBlockStmt, nkBlockExpr, nkIfStmt, - nkIfExpr, nkCaseStmt, nkWhen, nkWhileStmt, nkTryStmt}: + nkIfExpr, nkCaseStmt, nkWhen, nkWhileStmt, nkParForStmt, nkTryStmt}: template process(child, s): untyped = p(child, c, s, mode) handleNestedTempl(n, process) elif mode == sinkArg: |