@@ -6044,31 +6044,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
var rhs = node.right;
|
var rhs = node.right;
|
||||||
if (lhs instanceof AST_Destructured) {
|
if (lhs instanceof AST_Destructured) {
|
||||||
rhs.walk(tw);
|
rhs.walk(tw);
|
||||||
var marker = new TreeWalker(function(node) {
|
walk_destructured(AST_SymbolRef, mark, lhs);
|
||||||
if (node instanceof AST_Destructured) return;
|
|
||||||
if (node instanceof AST_DefaultValue) {
|
|
||||||
push();
|
|
||||||
node.value.walk(tw);
|
|
||||||
pop();
|
|
||||||
node.name.walk(marker);
|
|
||||||
} else if (node instanceof AST_DestructuredKeyVal) {
|
|
||||||
if (node.key instanceof AST_Node) {
|
|
||||||
push();
|
|
||||||
segment.block = node;
|
|
||||||
node.key.walk(tw);
|
|
||||||
node.value.walk(marker);
|
|
||||||
pop();
|
|
||||||
} else {
|
|
||||||
node.value.walk(marker);
|
|
||||||
}
|
|
||||||
} else if (node instanceof AST_SymbolRef) {
|
|
||||||
mark(node);
|
|
||||||
} else {
|
|
||||||
node.walk(tw);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
lhs.walk(marker);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (lazy_op[node.operator.slice(0, -1)]) {
|
if (lazy_op[node.operator.slice(0, -1)]) {
|
||||||
@@ -6196,15 +6172,15 @@ Compressor.prototype.compress = function(node) {
|
|||||||
if (node instanceof AST_Lambda) {
|
if (node instanceof AST_Lambda) {
|
||||||
if (node.name) references[node.name.definition().id] = false;
|
if (node.name) references[node.name.definition().id] = false;
|
||||||
var marker = node.uses_arguments && !tw.has_directive("use strict") ? function(node) {
|
var marker = node.uses_arguments && !tw.has_directive("use strict") ? function(node) {
|
||||||
if (node instanceof AST_SymbolFunarg) references[node.definition().id] = false;
|
references[node.definition().id] = false;
|
||||||
} : function(node) {
|
} : function(node) {
|
||||||
if (node instanceof AST_SymbolFunarg) mark(node);
|
mark(node);
|
||||||
};
|
};
|
||||||
in_arg.push(node);
|
in_arg.push(node);
|
||||||
node.argnames.forEach(function(argname) {
|
node.argnames.forEach(function(argname) {
|
||||||
argname.mark_symbol(marker, tw);
|
walk_destructured(AST_SymbolFunarg, marker, argname);
|
||||||
});
|
});
|
||||||
if (node.rest) node.rest.mark_symbol(marker, tw);
|
if (node.rest) walk_destructured(AST_SymbolFunarg, marker, node.rest);
|
||||||
in_arg.pop();
|
in_arg.pop();
|
||||||
}
|
}
|
||||||
walk_lambda(node, tw);
|
walk_lambda(node, tw);
|
||||||
@@ -6419,6 +6395,34 @@ Compressor.prototype.compress = function(node) {
|
|||||||
segment = Object.getPrototypeOf(segment);
|
segment = Object.getPrototypeOf(segment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function walk_destructured(symbol_type, mark, lhs) {
|
||||||
|
var marker = new TreeWalker(function(node) {
|
||||||
|
if (node instanceof AST_Destructured) return;
|
||||||
|
if (node instanceof AST_DefaultValue) {
|
||||||
|
push();
|
||||||
|
node.value.walk(tw);
|
||||||
|
pop();
|
||||||
|
node.name.walk(marker);
|
||||||
|
} else if (node instanceof AST_DestructuredKeyVal) {
|
||||||
|
if (node.key instanceof AST_Node) {
|
||||||
|
push();
|
||||||
|
segment.block = node;
|
||||||
|
node.key.walk(tw);
|
||||||
|
node.value.walk(marker);
|
||||||
|
pop();
|
||||||
|
} else {
|
||||||
|
node.value.walk(marker);
|
||||||
|
}
|
||||||
|
} else if (node instanceof symbol_type) {
|
||||||
|
mark(node);
|
||||||
|
} else {
|
||||||
|
node.walk(tw);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
lhs.walk(marker);
|
||||||
|
}
|
||||||
|
|
||||||
function mark(sym, read) {
|
function mark(sym, read) {
|
||||||
var def = sym.definition(), ldef;
|
var def = sym.definition(), ldef;
|
||||||
if (read && !all(in_arg, function(fn) {
|
if (read && !all(in_arg, function(fn) {
|
||||||
|
|||||||
@@ -2421,3 +2421,30 @@ issue_5463: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5465: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
merge_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b) {
|
||||||
|
(function(c = b = "FAIL 2") {
|
||||||
|
this && console.log(b || "PASS");
|
||||||
|
})(42 - a && a);
|
||||||
|
}
|
||||||
|
f("FAIL 1");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
a = "FAIL 1",
|
||||||
|
void function(c = b = "FAIL 2") {
|
||||||
|
this && console.log(b || "PASS");
|
||||||
|
}(42 - a && a);
|
||||||
|
var a, b;
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1815,8 +1815,8 @@ issue_4288: {
|
|||||||
console.log(typeof b);
|
console.log(typeof b);
|
||||||
}()]: a,
|
}()]: a,
|
||||||
}) {
|
}) {
|
||||||
var a = a;
|
var b = a;
|
||||||
a++;
|
b++;
|
||||||
}
|
}
|
||||||
f(0);
|
f(0);
|
||||||
}
|
}
|
||||||
@@ -1848,8 +1848,8 @@ issue_4294: {
|
|||||||
}) {}({
|
}) {}({
|
||||||
[a]: 0,
|
[a]: 0,
|
||||||
});
|
});
|
||||||
var a = A;
|
var b = A;
|
||||||
console.log(a);
|
console.log(b);
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
|
|||||||
Reference in New Issue
Block a user