identical_operands
Finds an operator with the same expression on both sides (a == a).
Category suspicious, warn by default.
#import "Basic";
Vec :: struct {
x: int;
y: int;
}
same :: (a: Vec, b: Vec) -> bool {
return a.x == b.x && a.y == a.y;
}
main :: () {
print("%\n", same(.{ 1, 2 }, .{ 1, 3 }));
}warning[identical_operands]: both sides of `==` are `a.y`
--> example.jai:9:26
|
9 | return a.x == b.x && a.y == a.y;
| ^^^^^^^^^^
|
= help: the result is always `true`; was one side meant to be something else?
= note: `identical_operands` is `warn` by default#import "Basic";
Vec :: struct {
x: int;
y: int;
}
same :: (a: Vec, b: Vec) -> bool {
return a.x == b.x && a.y == b.y;
}
main :: () {
print("%\n", same(.{ 1, 2 }, .{ 1, 3 }));
}Float ==, != and - are left alone (NaN tests), as are operator procedures.