@@ -509,10 +509,8 @@ var AST_Lambda = DEFNODE("Lambda", "name argnames length_read uses_arguments", {
|
||||
},
|
||||
each_argname: function(visit) {
|
||||
var tw = new TreeWalker(function(node) {
|
||||
if (node instanceof AST_DestructuredObject) {
|
||||
node.properties.forEach(function(prop) {
|
||||
prop.value.walk(tw);
|
||||
});
|
||||
if (node instanceof AST_DestructuredKeyVal) {
|
||||
node.value.walk(tw);
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_SymbolFunarg) visit(node);
|
||||
|
||||
@@ -4739,13 +4739,25 @@ merge(Compressor.prototype, {
|
||||
if (node === self) root = segment;
|
||||
if (node instanceof AST_Lambda) {
|
||||
if (node.name) references[node.name.definition().id] = false;
|
||||
node.each_argname(node.uses_arguments && !tw.has_directive("use strict") ? function(node) {
|
||||
references[node.definition().id] = false;
|
||||
var marker = node.uses_arguments && !tw.has_directive("use strict") ? function(node) {
|
||||
if (node instanceof AST_SymbolFunarg) references[node.definition().id] = false;
|
||||
} : function(node) {
|
||||
mark(node, false, true);
|
||||
if (node instanceof AST_SymbolFunarg) mark(node, false, true);
|
||||
};
|
||||
var scanner = new TreeWalker(function(ref) {
|
||||
if (!(ref instanceof AST_SymbolRef)) return;
|
||||
var def = ref.definition();
|
||||
var ldef = node.variables.get(ref.name);
|
||||
if (ldef && (ldef === def || def.undeclared || node.parent_scope.find_variable(ref) === def)) {
|
||||
references[ldef.id] = false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
node.argnames.forEach(function(argname) {
|
||||
argname.mark_symbol(marker, scanner);
|
||||
});
|
||||
}
|
||||
descend();
|
||||
walk_body(node, tw);
|
||||
pop();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1440,3 +1440,33 @@ issue_4286_2: {
|
||||
expect_stdout: "PASS"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
issue_4288: {
|
||||
options = {
|
||||
merge_vars: true,
|
||||
}
|
||||
input: {
|
||||
function f({
|
||||
[new function() {
|
||||
console.log(typeof b);
|
||||
}()]: a,
|
||||
}) {
|
||||
var b = a;
|
||||
b++;
|
||||
}
|
||||
f(0);
|
||||
}
|
||||
expect: {
|
||||
function f({
|
||||
[new function() {
|
||||
console.log(typeof b);
|
||||
}()]: a,
|
||||
}) {
|
||||
var b = a;
|
||||
b++;
|
||||
}
|
||||
f(0);
|
||||
}
|
||||
expect_stdout: "undefined"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user