Esc

lossy_xx

Finds xx that narrows a number to a smaller type.

Category pedantic, allow by default.

Off by default; the example is shown with the rule enabled.

Example
#import "Basic";

main :: () {
    big := 70000;
    small: u16 = xx big;
    print("%\n", small);
}
Diagnostic
warning[lossy_xx]: `xx` converts `s64` to `u16`, which can lose the high bits
  --> example.jai:5:18
   |
 5 |     small: u16 = xx big;
   |                  ^^^^^^
   |
help: write `cast(u16)` to make the conversion visible
   |
 5 ~     small: u16 = cast(u16) big;
   |
Fixed
#import "Basic";

main :: () {
    big := 70000;
    small: u16 = cast,trunc(u16) big;
    print("%\n", small);
}

Off by default: narrowing with xx is common Jai style.