-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
I stumbled upon the following internal error with the following code:
proc flatIterator[T](s: openarray[T]): auto {.noSideEffect.}=
result = iterator(): auto =
when (T is not seq|array):
for item in s:
yield item
else:
yield 123456
let it = flatIterator(@[@[1,2],@[3,4]])
Error
flatten_iterator.nim(2, 14) Error: internal error: expr: var not init result_104065
No stack traceback available
To create a stacktrace, rerun compilation with ./koch temp c <file>
Changing the signature to int works
proc flatIterator[T](s: openarray[T]): auto {.noSideEffect.}=
result = iterator(): int = #<------------ Now it compiles
when (T is not seq|array):
for item in s:
yield item
else:
yield 123456
let it = flatIterator(@[@[1,2],@[3,4]])
Context:
Following @zah suggestion in #5708. I'm trying to create a flat iterator that iterates on arbitrary nested openarrays. Inline iterators cannot be recursive (#555) so I'm trying through a closure iterator.