fix corner case in collapse_vars (#5574)

fixes #5573
This commit is contained in:
Alex Lam S.L
2022-07-23 00:18:26 +01:00
committed by GitHub
parent 56e9454f1f
commit b371dc2d1e
2 changed files with 29 additions and 1 deletions

View File

@@ -2593,7 +2593,8 @@ Compressor.prototype.compress = function(node) {
if (value instanceof AST_Array) return !all(node.elements, function(element, index) { if (value instanceof AST_Array) return !all(node.elements, function(element, index) {
return !arg_may_throw(reject, element, value[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); return !arg_may_throw(reject, element);
}); });
} }

View File

@@ -3817,3 +3817,30 @@ issue_5533_drop_fargs: {
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=6" 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"
}