Skip to content

Commit

Permalink
fix #14219 (#14225)
Browse files Browse the repository at this point in the history
Co-authored-by: cooldome <[email protected]>
  • Loading branch information
cooldome and cooldome authored May 11, 2020
1 parent 86669ef commit a39123c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/injectdestructors.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ proc injectDefaultCalls(n: PNode, c: var Con) =
proc extractDestroysForTemporaries(c: Con, destroys: PNode): PNode =
result = newNodeI(nkStmtList, destroys.info)
for i in 0..<destroys.len:
if destroys[i][1][0].sym.kind == skTemp:
if destroys[i][1][0].sym.kind in {skTemp, skForVar}:
result.add destroys[i]
destroys[i] = c.emptyNode

Expand Down
10 changes: 10 additions & 0 deletions tests/arc/amodule.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var vectors = @["a", "b", "c", "d", "e"]

iterator testVectors(): string =
for vector in vectors:
yield vector

var r = ""
for item in testVectors():
r.add item
echo r
6 changes: 6 additions & 0 deletions tests/arc/tamodule.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
discard """
output: "abcde"
cmd: "nim c --gc:arc $file"
"""

import amodule

0 comments on commit a39123c

Please sign in to comment.