erasing_op
Finds an operation that is always 0 (x * 0, x & 0).
Category suspicious, warn by default.
#import "Basic";
offset :: (row: int, col: int) -> int {
return row * 0 + col;
}
main :: () {
print("%\n", offset(2, 3));
}warning[erasing_op]: `row * 0` is always `0`
--> example.jai:4:12
|
4 | return row * 0 + col;
| ^^^^^^^
|
help: `*` with this literal erases `row`: was another value meant?
|
4 ~ return 0 + col;
|
= note: `erasing_op` is `warn` by default#import "Basic";
offset :: (row: int, col: int) -> int {
return row * 8 + col;
}
main :: () {
print("%\n", offset(2, 3));
}Left alone inside an index or array literal, where a 0 * lines up with other rows.