for
loop is unusable with types larger than usize
#17139
Labels
bug
Observed behavior contradicts documented or intended behavior
Zig Version
0.12.0-dev.185+49075d205
Steps to Reproduce and Observed Behavior
The documentation for
for
vaguely says thatWhat it doesn't say is the important disclaimer that
for
only works forusize
, which is a massive limitation.For instance, the following seemingly innocent loops do not compile (in caso of
tooBig
assuming thatusize
is at mostu64
):Expected Behavior
Unsurprisingly, the expected behavior is that the
for
loop should be able to handle negative numbers and arbitrarily large integers.I know that this kind of
for
loop is redundant and can always be reformulated in terms ofwhile
, but then what is the point of having such a limited construct which in many cases is either completely unusable or at best very cumbersome (requiring for instance@intCast
/@truncate
)?The text was updated successfully, but these errors were encountered: