Skip to content

Commit

Permalink
fix corner case in collapse_vars (#4797)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl committed Mar 17, 2021
1 parent d837a46 commit 7da49b5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/compress.js
Expand Up @@ -2428,6 +2428,7 @@ merge(Compressor.prototype, {
if (parent.condition !== node) return node;
return find_stop_value(parent, level + 1);
}
if (parent instanceof AST_Yield) return find_stop_value(parent, level + 1);
return null;
}

Expand Down
24 changes: 24 additions & 0 deletions test/compress/yields.js
Expand Up @@ -247,6 +247,30 @@ collapse_vars_4: {
node_version: ">=4"
}

collapse_vars_5: {
options = {
collapse_vars: true,
}
input: {
var a = function* f(b, c) {
b = yield c = b;
console.log(c);
}("PASS");
a.next();
a.next("FAIL");
}
expect: {
var a = function* f(b, c) {
b = yield c = b;
console.log(c);
}("PASS");
a.next();
a.next("FAIL");
}
expect_stdout: "PASS"
node_version: ">=4"
}

collapse_property_lambda: {
options = {
collapse_vars: true,
Expand Down

0 comments on commit 7da49b5

Please sign in to comment.