Esc

identical_branches

Finds an if/else or ifx whose branches are the same.

Category suspicious, warn by default.

Example
#import "Basic";

main :: () {
    n := 3;
    label := ifx n > 0 then "positive" else "positive";
    print("%\n", label);
}
Diagnostic
warning[identical_branches]: both branches of this `ifx` are the same
  --> example.jai:5:14
   |
 5 |     label := ifx n > 0 then "positive" else "positive";
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: the condition decides nothing: was one branch meant to differ?
   |
 5 ~     label := "positive";
   |
   = note: `identical_branches` is `warn` by default
Fixed
#import "Basic";

main :: () {
    n := 3;
    label := ifx n > 0 then "positive" else "not positive";
    print("%\n", label);
}

Compared by tokens. Empty branches, #if, and the last link of an else if chain are left alone.