fix corner case in collapse_vars

fixes #4633
This commit is contained in:
alexlamsl 2021-02-10 06:41:53 +08:00
parent 228cdf8e7e
commit b0820e30aa
2 changed files with 31 additions and 1 deletions

View File

@ -2009,7 +2009,7 @@ merge(Compressor.prototype, {
}; };
var tw = new TreeWalker(function(node) { var tw = new TreeWalker(function(node) {
if (!arg) return true; if (!arg) return true;
if (has_await(node)) { if (has_await(node) || node instanceof AST_Yield) {
arg = null; arg = null;
return true; return true;
} }

View File

@ -644,3 +644,33 @@ issue_4623: {
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=4" node_version: ">=4"
} }
issue_4633: {
options = {
collapse_vars: true,
unused: true,
}
input: {
var a = function*() {
(function(log) {
log(typeof this);
})(yield "PASS");
}();
console.log(a.next().value);
a.next(console.log);
}
expect: {
var a = function*() {
(function(log) {
log(typeof this);
})(yield "PASS");
}();
console.log(a.next().value);
a.next(console.log);
}
expect_stdout: [
"PASS",
"object",
]
node_version: ">=4"
}