Skip to content

{.closure.} iterator can only be used once #21166

Open
@iacore

Description

@iacore

Description

iterator abc: int {.closure.} =
  for i in [1, 2, 3]:
    yield i

proc defg(abc_inner: (iterator: int)) =
  echo "Iter 0"
  for i in abc_inner():
    echo i
  echo "Iter 1"
  for i in abc_inner():
    echo i

defg(abc)

Nim Version

Nim Compiler Version 1.6.10 [Linux: amd64]
Compiled at 2022-11-21
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: f151925
active boot switches: -d:release

Current Output

Iter 0
1
2
3
Iter 1

Expected Output

Iter 0
1
2
3
Iter 1
1
2
3

Possible Solution

No response

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationRelated to documentation content (not generation).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions