@@ -6513,8 +6513,10 @@ merge(Compressor.prototype, {
|
|||||||
return null;
|
return null;
|
||||||
}, true);
|
}, true);
|
||||||
if (trimmed.name) {
|
if (trimmed.name) {
|
||||||
def.name = trimmed.name;
|
def = make_node(AST_VarDef, def, {
|
||||||
def.value = value = trimmed.value;
|
name: trimmed.name,
|
||||||
|
value: value = trimmed.value,
|
||||||
|
});
|
||||||
flush();
|
flush();
|
||||||
} else if (trimmed.value) {
|
} else if (trimmed.value) {
|
||||||
side_effects.push(trimmed.value);
|
side_effects.push(trimmed.value);
|
||||||
@@ -6722,19 +6724,18 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
if (node instanceof AST_Assign) {
|
if (node instanceof AST_Assign) {
|
||||||
descend(node, tt);
|
descend(node, tt);
|
||||||
if (node.left instanceof AST_Destructured) {
|
if (!(node.left instanceof AST_Destructured)) return node;
|
||||||
var trimmed = trim_destructured(node.left, node.right, function(node) {
|
var trimmed = trim_destructured(node.left, node.right, function(node) {
|
||||||
return node;
|
return node;
|
||||||
}, node.write_only === true);
|
}, node.write_only === true);
|
||||||
if (!trimmed.name) {
|
if (trimmed.name) return make_node(AST_Assign, node, {
|
||||||
if (trimmed.value) return trimmed.value;
|
operator: node.operator,
|
||||||
if (parent instanceof AST_Sequence && parent.tail_node() !== node) return List.skip;
|
left: trimmed.name,
|
||||||
return make_node(AST_Number, node, { value: 0 });
|
right: trimmed.value,
|
||||||
}
|
});
|
||||||
node.left = trimmed.name;
|
if (trimmed.value) return trimmed.value;
|
||||||
node.right = trimmed.value;
|
if (parent instanceof AST_Sequence && parent.tail_node() !== node) return List.skip;
|
||||||
}
|
return make_node(AST_Number, node, { value: 0 });
|
||||||
return node;
|
|
||||||
}
|
}
|
||||||
if (node instanceof AST_LabeledStatement && node.body instanceof AST_For) {
|
if (node instanceof AST_LabeledStatement && node.body instanceof AST_For) {
|
||||||
// Certain combination of unused name + side effect leads to invalid AST:
|
// Certain combination of unused name + side effect leads to invalid AST:
|
||||||
|
|||||||
@@ -2948,3 +2948,53 @@ issue_5074_method_pure_getters: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5085_1: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unsafe: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "PASS";
|
||||||
|
var [ b ] = [ 42, a ], c = b ? 0 : a = "FAIL";
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "PASS";
|
||||||
|
var b = [ 42 ][0];
|
||||||
|
b;
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5085_2: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
unsafe: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "PASS";
|
||||||
|
(function(b) {
|
||||||
|
[ b ] = [ 42, a ];
|
||||||
|
var c = b ? 0 : a = "FAIL";
|
||||||
|
})();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "PASS";
|
||||||
|
(function(b) {
|
||||||
|
b = [ 42 ][0];
|
||||||
|
})();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user