fix corner case in reduce_vars (#5862)

fixes #5860
fixes #5861
This commit is contained in:
Alex Lam S.L
2024-06-21 01:29:11 +03:00
committed by GitHub
parent 95d3ede664
commit 205a1d1f19
2 changed files with 143 additions and 2 deletions

View File

@@ -985,7 +985,6 @@ Compressor.prototype.compress = function(node) {
var scan = ld || left instanceof AST_Destructured;
switch (node.operator) {
case "=":
if (ld) assign(tw, ld);
if (left.equals(right) && !left.has_side_effects(compressor)) {
right.walk(tw);
walk_prop(left);
@@ -1009,12 +1008,12 @@ Compressor.prototype.compress = function(node) {
case "||=":
case "??=":
var lazy = true;
if (ld) assign(tw, ld);
default:
if (!scan) {
mark_assignment_to_arguments(left);
return walk_lazy();
}
assign(tw, ld);
ld.assignments++;
var fixed = ld.fixed;
if (is_modified(compressor, tw, node, node, 0)) {
@@ -1083,6 +1082,7 @@ Compressor.prototype.compress = function(node) {
return;
}
var d = sym.definition();
assign(tw, d);
d.assignments++;
if (!fixed || sym.in_arg || !safe_to_assign(tw, d)) {
walk();
@@ -1613,6 +1613,7 @@ Compressor.prototype.compress = function(node) {
return node.value || make_node(AST_Undefined, node);
}, function(name, fixed) {
var d = name.definition();
assign(tw, d);
if (!d.first_decl && d.references.length == 0) d.first_decl = name;
if (fixed && safe_to_assign(tw, d, true)) {
mark(tw, d);