Allow recursive closure iterators (#19939)

This commit is contained in:
Tanguy 2022-06-30 23:19:04 +02:00 • committed by GitHub
commit ce4078acd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 5 deletions

View file

@ -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