Unsigned subrange type will not panic when overflow/underflow
What happened?
type
X = range[0'u8..64'u8]
Y = range[0'i8..64'i8]
var x: X = X.high
x.inc # nothing happened
echo x # 65
var y: Y = Y.high
y.inc # over- or underflow [OverflowDefect]
According to manual, both x.inc and y.inc should panic.
Nim Version
all nim versions.
Current Standard Output Logs
/home/derekdai/test.nim(8) test
/home/derekdai/.choosenim/toolchains/nim-#devel/lib/system/fatal.nim(53) sysFatal
Error: unhandled exception: over- or underflow [OverflowDefect]
### Expected Standard Output Logs
```shell
Should panic at line 6
/home/derekdai/test.nim(6) test
/home/derekdai/.choosenim/toolchains/nim-#devel/lib/system/fatal.nim(53) sysFatal
Error: unhandled exception: over- or underflow [OverflowDefect]
### Possible Solution
_No response_
### Additional Information
_No response_
Unsigned numbers don't produce overflows. I'm not sure if range of unsigned should.
As an alternative, you could make uint subranges behave the same way as modular types in Ada, so that the lower bound is always 0 and arithmetic is done modulo the upper bound + 1. This would ensure the uint never overflows while still respecting the bounds of the subrange. I don't think there is much reason to use a uint subrange as they are now, but this change would give them some utility.
Makes sense.
I know this issue is super old but I agree that there should be some form of modular type like Ada. Using a range of unsigned ints seems valid to me.