Esc

neg_cmp_float

Finds !(a < b) on floats, which differs from a >= b when a value is NaN.

Category pedantic, allow by default.

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

Example
#import "Basic";

within :: (x: float, limit: float) -> bool {
    return !(x < limit);
}

main :: () {
    print("%\n", within(1, 2));
}
Diagnostic
warning[neg_cmp_float]: `!(x < limit)` is not `x >= limit` when a float is NaN
  --> example.jai:4:12
   |
 4 |     return !(x < limit);
   |            ^^^^^^^^^^^^
   |
help: write the inverted comparison if NaN should not take the branch, or test for NaN explicitly if it should
   |
 4 ~     return x >= limit;
   |
Fixed
#import "Basic";

within :: (x: float, limit: float) -> bool {
    return x >= limit;
}

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

Every comparison with a NaN is false, so !(a < b) is true for NaN where a >= b is false.