@@ -823,16 +823,23 @@ merge(Compressor.prototype, {
|
|||||||
fn.argnames.forEach(function(sym, i) {
|
fn.argnames.forEach(function(sym, i) {
|
||||||
var arg = iife.args[i];
|
var arg = iife.args[i];
|
||||||
if (!arg) arg = make_node(AST_Undefined, sym);
|
if (!arg) arg = make_node(AST_Undefined, sym);
|
||||||
else arg.walk(new TreeWalker(function(node) {
|
else {
|
||||||
if (!arg) return true;
|
var tw = new TreeWalker(function(node) {
|
||||||
if (node instanceof AST_SymbolRef && fn.variables.has(node.name)) {
|
if (!arg) return true;
|
||||||
var s = node.definition().scope;
|
if (node instanceof AST_SymbolRef && fn.variables.has(node.name)) {
|
||||||
if (s !== scope) while (s = s.parent_scope) {
|
var s = node.definition().scope;
|
||||||
if (s === scope) return true;
|
if (s !== scope) while (s = s.parent_scope) {
|
||||||
|
if (s === scope) return true;
|
||||||
|
}
|
||||||
|
arg = null;
|
||||||
}
|
}
|
||||||
arg = null;
|
if (node instanceof AST_This && !tw.find_parent(AST_Scope)) {
|
||||||
}
|
arg = null;
|
||||||
}));
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
arg.walk(tw);
|
||||||
|
}
|
||||||
if (arg) candidates.push(make_node(AST_VarDef, sym, {
|
if (arg) candidates.push(make_node(AST_VarDef, sym, {
|
||||||
name: sym,
|
name: sym,
|
||||||
value: arg
|
value: arg
|
||||||
|
|||||||
@@ -2256,3 +2256,67 @@ issue_2187_3: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "1"
|
expect_stdout: "1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_2203_1: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
a = "FAIL";
|
||||||
|
console.log({
|
||||||
|
a: "PASS",
|
||||||
|
b: function() {
|
||||||
|
return function(c) {
|
||||||
|
return c.a;
|
||||||
|
}((String, (Object, this)));
|
||||||
|
}
|
||||||
|
}.b());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
a = "FAIL";
|
||||||
|
console.log({
|
||||||
|
a: "PASS",
|
||||||
|
b: function() {
|
||||||
|
return function(c) {
|
||||||
|
return c.a;
|
||||||
|
}((String, (Object, this)));
|
||||||
|
}
|
||||||
|
}.b());
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_2203_2: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
a = "PASS";
|
||||||
|
console.log({
|
||||||
|
a: "FAIL",
|
||||||
|
b: function() {
|
||||||
|
return function(c) {
|
||||||
|
return c.a;
|
||||||
|
}((String, (Object, function() {
|
||||||
|
return this;
|
||||||
|
}())));
|
||||||
|
}
|
||||||
|
}.b());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
a = "PASS";
|
||||||
|
console.log({
|
||||||
|
a: "FAIL",
|
||||||
|
b: function() {
|
||||||
|
return function(c) {
|
||||||
|
return (String, (Object, function() {
|
||||||
|
return this;
|
||||||
|
}())).a;
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
}.b());
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user