Allow recursive closure iterators (#19939)
This commit is contained in:
parent
2c0aaac304
commit
ce4078acd4
3 changed files with 16 additions and 5 deletions
|
|
@ -29,6 +29,7 @@ end
|
|||
9018
|
||||
@[1, 2]
|
||||
@[1, 2, 3]
|
||||
1
|
||||
'''
|
||||
"""
|
||||
|
||||
|
|
@ -274,3 +275,15 @@ iterator cc() {.closure.} =
|
|||
break
|
||||
|
||||
var a2 = cc
|
||||
|
||||
# bug #16876
|
||||
block:
|
||||
iterator a(num: int): int {.closure.} =
|
||||
if num == 1:
|
||||
yield num
|
||||
else:
|
||||
for i in a(num - 1):
|
||||
yield i
|
||||
|
||||
for i in a(5):
|
||||
echo i
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue