almost_swapped
Finds a = b; b = a;, a swap that sets both to b.
Category correctness, deny by default.
#import "Basic";
main :: () {
a := 1;
b := 2;
a = b;
b = a;
print("% %\n", a, b);
}error[almost_swapped]: this sets both `a` and `b` to `b`
--> example.jai:7:5
|
7 | a = b;
| ^^^^^^
|
help: to swap them, write `a, b = b, a;`
|
7 - a = b;
8 - b = a;
7 + a, b = b, a;
|
= note: `almost_swapped` is `deny` by default#import "Basic";
main :: () {
a := 1;
b := 2;
tmp := a;
a = b;
b = tmp;
print("% %\n", a, b);
}Two consecutive statements with side-effect-free sides of the same type.