fix corner case in assignments (#4522)

fixes #4521
This commit is contained in:
Alex Lam S.L
2021-01-08 05:03:21 +00:00
committed by GitHub
parent 6c419bc083
commit 7fe8c9150a
2 changed files with 17 additions and 3 deletions

View File

@@ -9948,9 +9948,9 @@ merge(Compressor.prototype, {
operator: self.right.operator + "=",
left: self.left,
right: self.right.right,
}).optimize(compressor);
});
}
else if (self.right.right instanceof AST_SymbolRef
if (self.right.right instanceof AST_SymbolRef
&& self.right.right.name == self.left.name
&& ASSIGN_OPS_COMMUTATIVE[self.right.operator]
&& !self.right.left.has_side_effects(compressor)) {
@@ -9959,7 +9959,7 @@ merge(Compressor.prototype, {
operator: self.right.operator + "=",
left: self.left,
right: self.right.left,
}).optimize(compressor);
});
}
}
if ((self.operator == "-=" || self.operator == "+="