You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creating an iterator-that-calls-an-iterator yields compiler error Error: internal error: expr: var not init counter_520093758
iterator counter(frm, to: int): int {.closure.} =
var x = frm
while x < to:
yield x
x += 1
proc makeCounter(frm: int): iterator(to2: int): int {.closure.} =
iterator(to2: int): int {.closure.} =
for x in counter(frm,to2):
yield x
var ctr = makeCounter(2)
echo ctr(5)
Nim Version
Nim Compiler Version 2.2.0 [Windows: amd64]
Compiled at 2024-10-02
Current Output
c:\Users\Mikey\source\blocks\nim\tst.nim(11, 9) Error: internal error: expr: var not init counter_520093759
No stack traceback available
To create a stacktrace, rerun compilation with './koch temp c <file>', see https://nim-lang.github.io/Nim/intern.html#debugging-the-compiler for details
Expected Output
No compiler internal error.
Known Workarounds
I'm unable to apply any of the workarounds I've seen for this issue.
However changing proc to template seems to fix the problem:
Additional Information
No response
The text was updated successfully, but these errors were encountered:
Description
Sounds like this is related to #17632 .
Creating an iterator-that-calls-an-iterator yields compiler error
Error: internal error: expr: var not init counter_520093758
Nim Version
Nim Compiler Version 2.2.0 [Windows: amd64]
Compiled at 2024-10-02
Current Output
Expected Output
Known Workarounds
I'm unable to apply any of the workarounds I've seen for this issue.
However changing
proc
totemplate
seems to fix the problem:Additional Information
No response
The text was updated successfully, but these errors were encountered: