Access implicit result trough envP in closures (#8471)

Reuse the existing machinery, most of the changes are only needed to
handle the `result = result` node in nkReturnStmt produced by the
closure iterator transform.

Fixes #338
This commit is contained in:
LemonBoy
2018-07-30 08:34:15 +02:00
committed by Andreas Rumpf
parent d07d148597
commit 1fc3a68205
2 changed files with 33 additions and 1 deletions

20
tests/iter/t338.nim Normal file
View File

@@ -0,0 +1,20 @@
discard """
output: '''0
1
2
3
4
'''
"""
proc moo(): iterator (): int =
iterator fooGen: int {.closure.} =
while true:
yield result
result.inc
return fooGen
var foo = moo()
for i in 0 .. 4:
echo foo()