type A = distinct array[4, uint8]
let a: A = cast[A]([uint8 0, 0, 1, 1])
iterator items(a: A): uint8 {.borrow.}
for b in a:
echo b
/root/.local/share/mise/installs/nim/2.0.2/lib/system/iterators.nim(35, 10) Error: internal error: proc has no result symbol
No stack traceback available
To create a stacktrace, rerun compilation with './koch temp r <file>', see https://nim-lang.github.io/Nim/intern.html#debugging-the-compiler for details
https://github.com/nim-lang/Nim/issues/21476 for the compiler crash
iterators cant be borrowed, you'll need to manually
iterator items(a: A): uint8 =
for i in cast[array[4,uint8]](a):
yield i
Don't use cast for distinct types, do a type conversion. There's also distinctBase from std/typetraits if you want to aviod typing.
for i in cast[array[4,uint8]](a):
yield i