Esc

impossible_comparison

Finds comparisons of one integer that never pass together (x > 5 && x < 3).

Category correctness, deny by default.

Example
#import "Basic";

is_live :: (code: int) -> bool {
    return code != 404 || code != 410;
}

main :: () {
    print("%\n", is_live(200));
}
Diagnostic
error[impossible_comparison]: `code != 404 || code != 410` is always `true`
  --> example.jai:4:12
   |
 4 |     return code != 404 || code != 410;
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: every integer passes one of these comparisons: was `&&` meant?
   |
 4 ~     return code != 404 && code != 410;
   |
   = note: `impossible_comparison` is `deny` by default
Fixed
#import "Basic";

is_live :: (code: int) -> bool {
    return code != 404 && code != 410;
}

main :: () {
    print("%\n", is_live(200));
}

Only integer expressions compared with integer literals, within one run of && or ||.