Skip to content

Commit

Permalink
fix corner case in collapse_vars (#5574)
Browse files Browse the repository at this point in the history
fixes #5573
  • Loading branch information
alexlamsl committed Jul 22, 2022
1 parent 56e9454 commit b371dc2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -2593,7 +2593,8 @@ Compressor.prototype.compress = function(node) {
if (value instanceof AST_Array) return !all(node.elements, function(element, index) {
return !arg_may_throw(reject, element, value[index]);
});
return value.is_string(compressor) && !all(node.elements, function(element) {
if (!value.is_string(compressor)) return true;
return !all(node.elements, function(element) {
return !arg_may_throw(reject, element);
});
}
Expand Down
27 changes: 27 additions & 0 deletions test/compress/destructured.js
Original file line number Diff line number Diff line change
Expand Up @@ -3817,3 +3817,30 @@ issue_5533_drop_fargs: {
expect_stdout: "PASS"
node_version: ">=6"
}

issue_5573: {
options = {
collapse_vars: true,
}
input: {
var log = console.log;
var a = "FAIL";
(function([ { [log(a)]: b } ]) {
A = 42;
})((a = "PASS", [ {} ]));
log(a, A);
}
expect: {
var log = console.log;
var a = "FAIL";
(function([ { [log(a)]: b } ]) {
A = 42;
})((a = "PASS", [ {} ]));
log(a, A);
}
expect_stdout: [
"PASS",
"PASS 42",
]
node_version: ">=6"
}

0 comments on commit b371dc2

Please sign in to comment.