Closed jeshecdom closed 4 months ago
It's actually
If the number of times is less than -2^31 or greater than 2^31 - 1, range check exception is thrown.
Not quite, range check is only thrown when the number is greater than $2^{31} - 1$. If the number is less than zero and even as low as $-2^{256}$, there is no exception
So, I guess that executing the repeat a negative number of times is equivalent to executing it 0 times?
@jeshecdom exactly so. I'll clarify that in a PR in a moment
In the repeat statement explanation:
https://docs.tact-lang.org/book/statements#repeat-loop
The sentence "Number of repetitions must be a non-negative 32-bit Int", could be understood as saying that it is a 32-bit unsigned integer. So, it may be better to include the allowed integer range. For example, as:
Number of repetitions must be a non-negative 32-bit Int, i.e., a number
x
such that0 <= x <= 2^31 - 1
.Or simply:
Number of repetitions must be a non-negative integer (
>= 0
) smaller or equal than2^31 - 1
.