New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using iterator within another iterator fails #3819

Closed
flyx opened this Issue Feb 3, 2016 · 3 comments

Comments

Projects
None yet
4 participants
@flyx
Copy link
Contributor

flyx commented Feb 3, 2016

proc represent(i: int): iterator(): string =
  result = iterator(): string =
    yield $i

proc represent(s: seq[int]): iterator(): string =
  result = iterator(): string =
    yield "["
    for i in s:
      var events = represent(i)
      for event in events():
        yield event
    yield "]"

let s = @[1, 2, 3]
var output = represent(s)

for item in output():
  echo item

Output:

[
]

Expected:

[
1
2
3
]

represent(int) gets called, but the iterator returned by it never executes.

@narimiran

This comment has been minimized.

Copy link
Member

narimiran commented Oct 9, 2018

Nim 0.19.0 echos the expected. Close.

@Araq

This comment has been minimized.

Copy link
Member

Araq commented Oct 9, 2018

@narimiran Please add this testcase to some of the iterator tests.

narimiran added a commit to narimiran/Nim that referenced this issue Oct 10, 2018

@narimiran

This comment has been minimized.

Copy link
Member

narimiran commented Oct 10, 2018

Please add this testcase to some of the iterator tests.

Done, see #9272.

@Araq Araq closed this in 462bff4 Oct 10, 2018

krux02 added a commit to krux02/Nim that referenced this issue Oct 15, 2018

narimiran added a commit to narimiran/Nim that referenced this issue Oct 31, 2018

narimiran added a commit to narimiran/Nim that referenced this issue Nov 1, 2018

narimiran added a commit that referenced this issue Nov 1, 2018

narimiran added a commit that referenced this issue Nov 1, 2018

Iter test: closes #3819 (#9272)
(cherry picked from commit 462bff4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment