@@ -11091,9 +11091,11 @@ merge(Compressor.prototype, {
|
|||||||
});
|
});
|
||||||
var scan_scope = new TreeWalker(function(node) {
|
var scan_scope = new TreeWalker(function(node) {
|
||||||
if (reachable) return true;
|
if (reachable) return true;
|
||||||
if (node instanceof AST_Scope && node !== self) {
|
if (node instanceof AST_Lambda && node !== self) {
|
||||||
var parent = scan_scope.parent();
|
if (!(is_async(node) || is_generator(node))) {
|
||||||
if (parent instanceof AST_Call && parent.expression === node) return;
|
var parent = scan_scope.parent();
|
||||||
|
if (parent instanceof AST_Call && parent.expression === node) return;
|
||||||
|
}
|
||||||
node.walk(find_ref);
|
node.walk(find_ref);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1780,3 +1780,92 @@ issue_5001: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=8"
|
node_version: ">=8"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5019_1: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function(a) {
|
||||||
|
(async function() {
|
||||||
|
await 42;
|
||||||
|
console.log(a);
|
||||||
|
})();
|
||||||
|
a = "PASS";
|
||||||
|
})("FAIL");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function(a) {
|
||||||
|
(async function() {
|
||||||
|
await 42;
|
||||||
|
console.log(a);
|
||||||
|
})();
|
||||||
|
a = "PASS";
|
||||||
|
})("FAIL");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5019_2: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log("sync", function(a) {
|
||||||
|
(async function() {
|
||||||
|
console.log(await "async", a);
|
||||||
|
})();
|
||||||
|
return a = "PASS";
|
||||||
|
}("FAIL"));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("sync", function(a) {
|
||||||
|
(async function() {
|
||||||
|
console.log(await "async", a);
|
||||||
|
})();
|
||||||
|
return a = "PASS";
|
||||||
|
}("FAIL"));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"sync PASS",
|
||||||
|
"async PASS",
|
||||||
|
]
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5019_3: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
for (var i in "foo") {
|
||||||
|
(function(a) {
|
||||||
|
(async function() {
|
||||||
|
console.log(await "async", a);
|
||||||
|
})();
|
||||||
|
})(i);
|
||||||
|
console.log("sync", i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
for (var i in "foo") {
|
||||||
|
(function(a) {
|
||||||
|
(async function() {
|
||||||
|
console.log(await "async", a);
|
||||||
|
})();
|
||||||
|
})(i);
|
||||||
|
console.log("sync", i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"sync 0",
|
||||||
|
"sync 1",
|
||||||
|
"sync 2",
|
||||||
|
"async 0",
|
||||||
|
"async 1",
|
||||||
|
"async 2",
|
||||||
|
]
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1083,3 +1083,62 @@ issue_4769_2: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5019_1: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function(a) {
|
||||||
|
return a = function*() {
|
||||||
|
console.log(typeof a);
|
||||||
|
}();
|
||||||
|
})().next();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function(a) {
|
||||||
|
return a = function*() {
|
||||||
|
console.log(typeof a);
|
||||||
|
}();
|
||||||
|
})().next();
|
||||||
|
}
|
||||||
|
expect_stdout: "object"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5019_2: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = [];
|
||||||
|
for (var b in "foo")
|
||||||
|
a.push(function(c) {
|
||||||
|
return function*() {
|
||||||
|
console.log(c);
|
||||||
|
}();
|
||||||
|
}(b));
|
||||||
|
a.map(function(d) {
|
||||||
|
return d.next();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = [];
|
||||||
|
for (var b in "foo")
|
||||||
|
a.push(function(c) {
|
||||||
|
return function*() {
|
||||||
|
console.log(c);
|
||||||
|
}();
|
||||||
|
}(b));
|
||||||
|
a.map(function(d) {
|
||||||
|
return d.next();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"0",
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
]
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user