parent
e4bff315eb
commit
eb22f0101e
|
|
@ -7937,7 +7937,14 @@ Compressor.prototype.compress = function(node) {
|
||||||
drop = false;
|
drop = false;
|
||||||
value = value.fixed_value();
|
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;
|
var elements = [], newValues = drop && [], pos = 0;
|
||||||
node.elements.forEach(function(element, index) {
|
node.elements.forEach(function(element, index) {
|
||||||
value = values && values[index];
|
value = values && values[index];
|
||||||
|
|
@ -7988,8 +7995,9 @@ Compressor.prototype.compress = function(node) {
|
||||||
value = value.clone();
|
value = value.clone();
|
||||||
value.elements = newValues;
|
value.elements = newValues;
|
||||||
}
|
}
|
||||||
if (!node.rest && (value instanceof AST_Array
|
if (!native) {
|
||||||
|| value && value.is_string(compressor))) switch (elements.length) {
|
elements.length = node.elements.length;
|
||||||
|
} else if (!node.rest) switch (elements.length) {
|
||||||
case 0:
|
case 0:
|
||||||
if (node === root) break;
|
if (node === root) break;
|
||||||
if (drop) value = value.drop_side_effect_free(compressor);
|
if (drop) value = value.drop_side_effect_free(compressor);
|
||||||
|
|
|
||||||
|
|
@ -2713,7 +2713,7 @@ issue_5533_2_drop_fargs: {
|
||||||
try {
|
try {
|
||||||
(function() {
|
(function() {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
var [ [] = [] ] = [];
|
var [ [ , ] = [] ] = [];
|
||||||
throw "PASS";
|
throw "PASS";
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -1306,7 +1306,7 @@ keep_reference: {
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var a = [ {}, 42 ];
|
var a = [ {}, 42 ];
|
||||||
var [ b ] = a;
|
var b = a[0];
|
||||||
console.log(a[0] === b ? "PASS" : "FAIL");
|
console.log(a[0] === b ? "PASS" : "FAIL");
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
|
|
|
||||||
|
|
@ -1735,3 +1735,37 @@ issue_5576: {
|
||||||
]
|
]
|
||||||
node_version: ">=10"
|
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"
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user