Esc

unnecessary_force_cast

Finds cast,force where the value already has the type or the conversion widens.

Category complexity, warn by default.

Example
#import "Basic";

widen :: (a: s32) -> s64 {
    return cast,force(s64) a;
}

main :: () {
    print("%\n", widen(7));
}
Diagnostic
warning[unnecessary_force_cast]: `cast,force` from `s32` to `s64` reinterprets nothing and has no range to check
  --> example.jai:4:12
   |
 4 |     return cast,force(s64) a;
   |            ^^^^^^^^^^^^^^
   |
help: remove `,force`: the plain cast does the same
   |
 4 ~     return cast(s64) a;
   |
   = note: `unnecessary_force_cast` is `warn` by default
Fixed
#import "Basic";

widen :: (a: s32) -> s64 {
    return cast(s64) a;
}

main :: () {
    print("%\n", widen(7));
}

,force reinterprets the bits of a number as a float (or back) or of an aggregate as another of the same size, and also skips the range check a plain cast makes when it narrows an integer.