Esc

wrapping_constant

Finds a constant that wraps to the type the other operand gives it ((0xffff_ffff - 40) / h).

Category correctness, deny by default.

Example
#import "Basic";

bucket :: (id: s32) -> s32 {
    return id % 0x8000_0000;
}

main :: () {
    print("%\n", bucket(5));
}
Diagnostic
error[wrapping_constant]: constant `0x8000_0000` is 2147483648, which does not fit in `s32`: `%` uses it as -2147483648
  --> example.jai:4:17
   |
 4 |     return id % 0x8000_0000;
   |                 ^^^^^^^^^^^ `s32` comes from `id`
   |
help: to use 2147483648, compute in `s64` (`cast(s64) id`); to mean -2147483648, write -2147483648
   |
 4 ~     return cast(s64) id % 0x8000_0000;
   |
   = note: `wrapping_constant` is `deny` by default
Fixed
#import "Basic";

bucket :: (id: s32) -> s32 {
    return id % 0x7fff_ffff;
}

main :: () {
    print("%\n", bucket(5));
}

A constant takes the other operand's type, so the first divides -41 by h.