scan within IIFEs of assigned values (#2702)

fixes #2701
This commit is contained in:
Alex Lam S.L
2018-01-02 01:24:23 +08:00
committed by GitHub
parent 673b071637
commit 2f3bddbaca
2 changed files with 30 additions and 3 deletions

View File

@@ -4913,9 +4913,8 @@ merge(Compressor.prototype, {
if (reachable) return true;
if (node instanceof AST_Scope && node !== self) {
var parent = scan_scope.parent();
if (!(parent instanceof AST_Call && parent.expression === node)) {
if (parent instanceof AST_Call && parent.expression === node) return;
node.walk(find_ref);
}
return true;
}
});

View File

@@ -881,3 +881,31 @@ issue_2692: {
}
expect_stdout: "function"
}
issue_2701: {
options = {
dead_code: true,
inline: false,
}
input: {
function f(a) {
return a = function() {
return function() {
return a;
};
}();
}
console.log(typeof f()());
}
expect: {
function f(a) {
return a = function() {
return function() {
return a;
};
}();
}
console.log(typeof f()());
}
expect_stdout: "function"
}