@@ -7937,7 +7937,14 @@ Compressor.prototype.compress = function(node) {
|
||||
drop = false;
|
||||
value = value.fixed_value();
|
||||
}
|
||||
var values = value instanceof AST_Array && value.elements;
|
||||
var native, values;
|
||||
if (value instanceof AST_Array) {
|
||||
native = true;
|
||||
values = value.elements;
|
||||
} else {
|
||||
native = value && value.is_string(compressor);
|
||||
values = false;
|
||||
}
|
||||
var elements = [], newValues = drop && [], pos = 0;
|
||||
node.elements.forEach(function(element, index) {
|
||||
value = values && values[index];
|
||||
@@ -7988,8 +7995,9 @@ Compressor.prototype.compress = function(node) {
|
||||
value = value.clone();
|
||||
value.elements = newValues;
|
||||
}
|
||||
if (!node.rest && (value instanceof AST_Array
|
||||
|| value && value.is_string(compressor))) switch (elements.length) {
|
||||
if (!native) {
|
||||
elements.length = node.elements.length;
|
||||
} else if (!node.rest) switch (elements.length) {
|
||||
case 0:
|
||||
if (node === root) break;
|
||||
if (drop) value = value.drop_side_effect_free(compressor);
|
||||
|
||||
@@ -2713,7 +2713,7 @@ issue_5533_2_drop_fargs: {
|
||||
try {
|
||||
(function() {
|
||||
for (;;) {
|
||||
var [ [] = [] ] = [];
|
||||
var [ [ , ] = [] ] = [];
|
||||
throw "PASS";
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1306,7 +1306,7 @@ keep_reference: {
|
||||
}
|
||||
expect: {
|
||||
var a = [ {}, 42 ];
|
||||
var [ b ] = a;
|
||||
var b = a[0];
|
||||
console.log(a[0] === b ? "PASS" : "FAIL");
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
|
||||
@@ -1735,3 +1735,37 @@ issue_5576: {
|
||||
]
|
||||
node_version: ">=10"
|
||||
}
|
||||
|
||||
issue_5663: {
|
||||
options = {
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var [ , a ] = function*() {
|
||||
console.log("foo");
|
||||
yield console.log("bar");
|
||||
console.log("baz");
|
||||
yield console.log("moo");
|
||||
console.log("moz");
|
||||
yield FAIL;
|
||||
}();
|
||||
}
|
||||
expect: {
|
||||
var [ , , ] = function*() {
|
||||
console.log("foo");
|
||||
yield console.log("bar");
|
||||
console.log("baz");
|
||||
yield console.log("moo");
|
||||
console.log("moz");
|
||||
yield FAIL;
|
||||
}();
|
||||
}
|
||||
expect_stdout: [
|
||||
"foo",
|
||||
"bar",
|
||||
"baz",
|
||||
"moo",
|
||||
]
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user