Unsigned integers are accumulated in uint64 and then cast directly to the target type without range checks. Signed integers rely on conversions that fail as defects in debug builds but become unchecked in release builds because module-wide checks are disabled.
Build with/without -d:release:
import jsony
doAssert "256".fromJson(uint8) == 0'u8
doAssert "999999999999999999999999".fromJson(uint8) == 255'u8
when defined(release):
doAssert "128".fromJson(int8) == -128'i8
doAssert "-129".fromJson(int8) == 127'i8
echo "release signed wraparound reproduced"
else:
discard "128".fromJson(int8)
Found by GPT 5.4.
Unsigned integers are accumulated in
uint64and then cast directly to the target type without range checks. Signed integers rely on conversions that fail as defects in debug builds but become unchecked in release builds because module-wide checks are disabled.Build with/without
-d:release:Found by GPT 5.4.