Skip to content

Commit

Permalink
Dont produce initing moves for sfNoInit variables in closure env (#21026
Browse files Browse the repository at this point in the history
)

(cherry picked from commit c47d519)
  • Loading branch information
yglukhov authored and narimiran committed Apr 25, 2023
1 parent 5714cce commit 0ce68bf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/injectdestructors.nim
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,10 @@ proc p(n: PNode; c: var Con; s: var Scope; mode: ProcessMode): PNode =
if ri.kind != nkEmpty:
result.add moveOrCopy(v, ri, c, s, isDecl = v.kind == nkSym)
elif ri.kind == nkEmpty and c.inLoop > 0:
result.add moveOrCopy(v, genDefaultCall(v.typ, c, v.info), c, s, isDecl = v.kind == nkSym)
let skipInit = v.kind == nkDotExpr and # Closure var
sfNoInit in v[1].sym.flags
if not skipInit:
result.add moveOrCopy(v, genDefaultCall(v.typ, c, v.info), c, s, isDecl = v.kind == nkSym)
else: # keep the var but transform 'ri':
var v = copyNode(n)
var itCopy = copyNode(it)
Expand Down

0 comments on commit 0ce68bf

Please sign in to comment.