|
check: -1'i16 == cast[int16](a) |
When parsing a negative number into a signed stint smaller than the word size, we must left-extend the sign or the general stint representation becomes inconsistent.
The given example works only because cast is used which hides the bug, which otherwise can be observed like this:
doAssert "0b1111111111111111".parse(StInt[16], 2).isNegative()
doAssert "0b1111111111111111".parse(StInt[16], 2).truncate(int16) == -1