The addition (+=
) and negative (-=
) assignments add and subtract, respectively, the
value of the right operand to the left operand and update the same. For the following
cases, they might have odd compounds, and there might be a bug risk:
x += x + y // result: 2x + y
x += x - y // result: 2x - y
x -= x + y // result: -y
x -= x - y // result: y
It is recommended to audit this manually and then decide whether to fix the issue or ignore it.
// WARNING: Please audit before fixing this issue
x += x + y // result: 2x + y
x += x - y // result: 2x - y
x -= x + y // result: -y
x -= x - y // result: y
// WARNING: Please audit before fixing this issue
x += y // result: x + y
x += -y // result: x - y
x -= y // result: x - y
x -= -y // result: x + y