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
The following code fails to compile. It was a bit difficult to isolate the problem: Strangely, the problem disappears by removing either the when condition or one of the loops:
when true: # removing 'when' indentation => compiles
iterator iter(): int {.closure.} =
yield 0
yield 1
iterator wrappedIterator(it: iterator (): int): int {.closure.} =
for x in it():
yield x
# Removing this loop => compiles, but
# the behavior of the second loop is strange:
# It is an infinite loop, always returning zero
for x in iter():
echo x
# Removing this loop => compiles, and above
# loop works fine.
for x in iter.wrappedIterator:
echo x
The compilation error is:
/home/fabian/github/NimExperiments/nimcache/repeatedIteratorUse.c: In function ‘repeatedIteratorUseInit’:
/home/fabian/github/NimExperiments/nimcache/repeatedIteratorUse.c:267:42: error: ‘HEX3Aenv_90222’ undeclared (first use in this function)
LOC8.ClPrc = iter_90003; LOC8.ClEnv = HEX3Aenv_90222;
^
/home/fabian/github/NimExperiments/nimcache/repeatedIteratorUse.c:267:42: note: each undeclared identifier is reported only once for each function it appears in
I also do not understand why iter.wrappedIterator causes an infinite loop in the first place. Is this behavior expected? From my newbie point of view, I was expecting just to get the exact same iteration as in the first loop.
For sake of completeness: There is now a separate issue #2563 addressing the cause of the infinite loop I observed. Thus, this issue is only about the compilation error.
The following code fails to compile. It was a bit difficult to isolate the problem: Strangely, the problem disappears by removing either the
when
condition or one of the loops:The compilation error is:
I also do not understand why
iter.wrappedIterator
causes an infinite loop in the first place. Is this behavior expected? From my newbie point of view, I was expecting just to get the exact same iteration as in the first loop.(Nim 0.10.3 -- using 28ecf72)
The text was updated successfully, but these errors were encountered: