Skip to content

Conversation

@ringabout
Copy link
Member

@ringabout ringabout commented Oct 14, 2025

fixes #25046

proc makeiter(v: string): iterator(): string =
  return iterator(): string =
    yield v

# loops
for c in makeiter("test")():
  echo "loops ", c

becomes

var temp = makeiter("test")
for c in temp():
  echo "loops ", c

for closures that might have side effects

@Araq Araq merged commit 31d64b5 into devel Oct 15, 2025
21 checks passed
@Araq Araq deleted the pr_schlau branch October 15, 2025 10:11
@github-actions
Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from 31d64b5

Hint: mm: orc; opt: speed; options: -d:release
183162 lines; 8.238s; 661.699MiB peakmem

narimiran pushed a commit that referenced this pull request Oct 17, 2025
fixes #25046

```nim
proc makeiter(v: string): iterator(): string =
  return iterator(): string =
    yield v

# loops
for c in makeiter("test")():
  echo "loops ", c
```
becomes

```nim
var temp = makeiter("test")
for c in temp():
  echo "loops ", c
```
for closures that might have side effects

(cherry picked from commit 31d64b5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infinite loop with anonymous iterator

3 participants