Esc

bitwise_precedence

Finds a bitwise operator that binds differently than in C (1 << n - 1).

Category suspicious, warn by default.

Example
#import "Basic";

low_bits :: (bits: int) -> int {
    return 1 << bits - 1;
}

main :: () {
    print("%\n", low_bits(4));
}
Diagnostic
warning[bitwise_precedence]: `<<` binds tighter than `-` in Jai, unlike in C
  --> example.jai:4:12
   |
 4 |     return 1 << bits - 1;
   |            ^^^^^^^^^^^^^
   |
help: `<<` binds first here: write `(1 << bits)`
   |
 4 ~     return (1 << bits) - 1;
   |
   = note: `bitwise_precedence` is `warn` by default
Fixed
#import "Basic";

low_bits :: (bits: int) -> int {
    return (1 << bits) - 1;
}

main :: () {
    print("%\n", low_bits(4));
}

Jai gives all bitwise and shift operators one level above *, grouped left to right, so 1 << n - 1 is (1 << n) - 1.