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
20 lines
228 B
Nim
20 lines
228 B
Nim
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()
|