Esc

misrefactored_assign_op

Finds a += a + b, an update that applies the operator to a twice.

Category correctness, deny by default.

Example
#import "Basic";

main :: () {
    total := 10;
    price := 5;

    total += total + price;

    print("%\n", total);
}
Diagnostic
error[misrefactored_assign_op]: `total += total + ...` applies `+` to `total` twice
  --> example.jai:7:5
   |
 7 |     total += total + price;
   |     ^^^^^^^^^^^^^^^^^^^^^^
   |
help: `+=` already starts from `total`: write `total += price`
   |
 7 ~     total += price;
   |
   = note: `misrefactored_assign_op` is `deny` by default
Fixed
#import "Basic";

main :: () {
    total := 10;
    price := 5;

    total += price;

    print("%\n", total);
}

The same operator on both sides, a side-effect-free target of a number type spelled the same in both places (a op= a op b), and for + * & | ^ on integers also a op= b op a.