What should List.range {start: At 255u8, end: Length 2}
do?
return [255, 0]
?
panic?
return a result that is an error (in which case, the return type of List.range needs to change)?
other?
I would expect that to match the behavior of 255u8 + 2
(so, panic, I think?)
Does the case feel exceptional enough to merit a panic as opposed to returning an error? I guess generally people don't use U8 with List.range
so maybe.
+1 on panic too
I guess the same would apply to after? Though it does get more complex.
List.range { start: After 250u8, end: At 255 }
-> [251, 252, 253, 254, 255]
List.range { start: After 250u8, end: At 255 , step: 10}
should panic? since 250 + 10 is an overflow? Or should it be an empty list []
?
As an extra not, this works fine:
List.range { start: After 250u8, end: At 245 , step: 10}
It returns an empty list []
. Since it is going in reverse. 250 - 10 = 240, which exits immediately.
My gut feeling is that any call that doesn't use Length
should never panic. It should just be an empty list because nothing is contained in the range. Length is special because you can actually run out of elements.
that feels right to me too
Last updated: Jul 06 2025 at 12:14 UTC