fix corner case in merge_vars (#5609)
This commit is contained in:
@@ -6474,16 +6474,13 @@ Compressor.prototype.compress = function(node) {
|
|||||||
} else {
|
} else {
|
||||||
assigned = segment.block instanceof AST_ForEnumeration && segment.block.init === tw.parent();
|
assigned = segment.block instanceof AST_ForEnumeration && segment.block.init === tw.parent();
|
||||||
}
|
}
|
||||||
node.name.mark_symbol(assigned ? function(node) {
|
walk_destructured(AST_SymbolDeclaration, assigned ? function(node) {
|
||||||
if (!(node instanceof AST_SymbolDeclaration)) return;
|
|
||||||
if (node instanceof AST_SymbolVar) {
|
if (node instanceof AST_SymbolVar) {
|
||||||
mark(node);
|
mark(node);
|
||||||
} else {
|
} else {
|
||||||
references[node.definition().id] = false;
|
references[node.definition().id] = false;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
} : function(node) {
|
} : function(node) {
|
||||||
if (!(node instanceof AST_SymbolDeclaration)) return;
|
|
||||||
var id = node.definition().id;
|
var id = node.definition().id;
|
||||||
if (!(node instanceof AST_SymbolVar)) {
|
if (!(node instanceof AST_SymbolVar)) {
|
||||||
references[id] = false;
|
references[id] = false;
|
||||||
@@ -6492,8 +6489,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
} else if (references[id]) {
|
} else if (references[id]) {
|
||||||
references[id].push(node);
|
references[id].push(node);
|
||||||
}
|
}
|
||||||
return true;
|
}, node.name);
|
||||||
}, tw);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (node instanceof AST_While) {
|
if (node instanceof AST_While) {
|
||||||
@@ -6613,13 +6609,16 @@ Compressor.prototype.compress = function(node) {
|
|||||||
pop();
|
pop();
|
||||||
node.name.walk(marker);
|
node.name.walk(marker);
|
||||||
} else if (node instanceof AST_DestructuredKeyVal) {
|
} else if (node instanceof AST_DestructuredKeyVal) {
|
||||||
if (node.key instanceof AST_Node) {
|
if (!(node.key instanceof AST_Node)) {
|
||||||
|
node.value.walk(marker);
|
||||||
|
} else if (node.value instanceof AST_PropAccess) {
|
||||||
push();
|
push();
|
||||||
segment.block = node;
|
segment.block = node;
|
||||||
node.key.walk(tw);
|
node.key.walk(tw);
|
||||||
node.value.walk(marker);
|
node.value.walk(marker);
|
||||||
pop();
|
pop();
|
||||||
} else {
|
} else {
|
||||||
|
node.key.walk(tw);
|
||||||
node.value.walk(marker);
|
node.value.walk(marker);
|
||||||
}
|
}
|
||||||
} else if (node instanceof symbol_type) {
|
} else if (node instanceof symbol_type) {
|
||||||
|
|||||||
@@ -1718,7 +1718,7 @@ issue_4540: {
|
|||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_4548: {
|
issue_4548_1: {
|
||||||
options = {
|
options = {
|
||||||
merge_vars: true,
|
merge_vars: true,
|
||||||
toplevel: true,
|
toplevel: true,
|
||||||
@@ -1744,6 +1744,32 @@ issue_4548: {
|
|||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4548_2: {
|
||||||
|
options = {
|
||||||
|
merge_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
A = "foo";
|
||||||
|
var a = A;
|
||||||
|
var [ b = c = "bar" ] = [ console, console.log(a) ];
|
||||||
|
console.log(c);
|
||||||
|
var c;
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
A = "foo";
|
||||||
|
var a = A;
|
||||||
|
var [ b = c = "bar" ] = [ console, console.log(a) ];
|
||||||
|
console.log(c);
|
||||||
|
var c;
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"undefined",
|
||||||
|
]
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
issue_4588_1_unused: {
|
issue_4588_1_unused: {
|
||||||
options = {
|
options = {
|
||||||
unused: true,
|
unused: true,
|
||||||
|
|||||||
@@ -1902,8 +1902,8 @@ issue_4288: {
|
|||||||
console.log(typeof b);
|
console.log(typeof b);
|
||||||
}()]: a,
|
}()]: a,
|
||||||
}) {
|
}) {
|
||||||
var b = a;
|
var a = a;
|
||||||
b++;
|
a++;
|
||||||
}
|
}
|
||||||
f(0);
|
f(0);
|
||||||
}
|
}
|
||||||
@@ -2076,17 +2076,16 @@ issue_4312: {
|
|||||||
console.log(a);
|
console.log(a);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var a;
|
|
||||||
b = "PASS",
|
b = "PASS",
|
||||||
c = "FAIL",
|
c = "FAIL",
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
[a = b]: d,
|
[c = b]: d,
|
||||||
},
|
},
|
||||||
] = [ c && c ],
|
] = [ c && c ],
|
||||||
void 0;
|
void 0;
|
||||||
var b, c, d;
|
var b, c, d;
|
||||||
console.log(a);
|
console.log(c);
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
|
|||||||
Reference in New Issue
Block a user