duplicate_condition
Finds an else if that repeats an earlier condition.
Category suspicious, warn by default.
#import "Basic";
describe :: (key: int) {
if key == 1 print("one\n");
else if key == 2 print("two\n");
else if key == 1 print("uno\n");
}
main :: () {
describe(1);
}warning[duplicate_condition]: `key == 1` was already tested earlier in this chain
--> example.jai:6:13
|
6 | else if key == 1 print("uno\n");
| ^^^^^^^^
|
help: this branch can never run: was another condition meant?
|
6 - else if key == 1 print("uno\n");
|
= note: `duplicate_condition` is `warn` by default#import "Basic";
describe :: (key: int) {
if key == 1 print("one\n");
else if key == 2 print("two\n");
else if key == 3 print("three\n");
}
main :: () {
describe(1);
}Conditions must be side-effect-free; a call in between restarts the comparison.