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
iteratormyiterclosure(cps: seq[int]): int {.closure.} =echo cps
for cp in cps:
echo"loop"var dcps: seq[int] =@[1,2]
for dcp in dcps:
yield dcp
echo cps
echo"end"var myseqnum =@[1,2,3,4,5]
for myI inmyiterclosure(myseqnum):
echo myI
$ nim --run c some
@[1, 2, 3, 4, 5]
loop
1
2
@[1, 2, 3, 4, 5]
Traceback (most recent call last)
mybuggyiterator.nim(13) mybuggyiterator
system.nim(3772) myiterclosure
system.nim(3741) failedAssertImpl
system.nim(3733) raiseAssert
system.nim(2799) sysFatal
Error: unhandled exception: len(a) == L seq modified while iterating over it [AssertionError]
Tried on devel
Edit: works if I remove the inner loop.
The text was updated successfully, but these errors were encountered:
The following code throws an assertion error:
Tried on devel
Edit: works if I remove the inner loop.
The text was updated successfully, but these errors were encountered: