bool_to_int_with_if
Finds ifx c then 1 else 0, a bool turned into an integer with a branch.
Category pedantic, allow by default.
Off by default; the example is shown with the rule enabled.
#import "Basic";
main :: () {
ready := true;
count := ifx ready then 1 else 0;
print("%\n", count);
}warning[bool_to_int_with_if]: a `bool` is turned into an integer with a branch
--> example.jai:5:14
|
5 | count := ifx ready then 1 else 0;
| ^^^^^^^^^^^^^^^^^^^^^^^
|
help: write `cast(s64) ready`
|
5 ~ count := cast(s64) ready;
|#import "Basic";
main :: () {
ready := true;
count := cast(int) ready;
print("%\n", count);
}Off by default, since many read the ifx more easily than the cast.