fix corner case in assignments (#5426)

fixes #5425
This commit is contained in:
Alex Lam S.L
2022-04-19 13:19:30 +08:00
committed by GitHub
parent fbdb7eeda3
commit a0c0c294c5
2 changed files with 31 additions and 3 deletions

View File

@@ -11139,9 +11139,15 @@ Compressor.prototype.compress = function(node) {
&& assign instanceof AST_Assign
&& assign.operator == "="
&& self.left.equivalent_to(assign.left)) {
self.right = assign.right;
assign.right = self;
return assign;
return make_node(AST_Assign, self, {
operator: "=",
left: assign.left,
right: make_node(AST_Binary, self, {
operator: self.operator,
left: self.left,
right: assign.right,
}),
}).optimize(compressor);
}
}
if (compressor.option("comparisons")) switch (self.operator) {