Esc

shift_overflow

Finds a shift by at least the bit width of its operand (x << 40 with x: s32).

Category suspicious, warn by default.

Example
#import "Basic";

high_word :: (bits: u32) -> u32 {
    return bits << 32;
}

main :: () {
    print("%\n", high_word(1));
}
Diagnostic
warning[shift_overflow]: shifting a `u32` by 32 shifts out all 32 of its bits
  --> example.jai:4:12
   |
 4 |     return bits << 32;
   |            ^^^^^^^^^^
   |
   = help: the shift count must be below 32; widen the value first, `(cast(u64) x) << 32`, if more bits are needed
   = note: `shift_overflow` is `warn` by default
Fixed
#import "Basic";

high_word :: (bits: u64) -> u64 {
    return bits << 32;
}

main :: () {
    print("%\n", high_word(1));
}

The result is 0 (or -1 for >> on a negative signed value) whatever the operand holds, and the compiler accepts it.