Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix corner case in collapse_vars #3885

Merged
merged 1 commit into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,7 @@ merge(Compressor.prototype, {
col: node.start.col
});
if (candidate instanceof AST_UnaryPostfix) {
delete candidate.expression.fixed;
return make_node(AST_UnaryPrefix, candidate, candidate);
}
if (candidate instanceof AST_VarDef) {
Expand Down
25 changes: 25 additions & 0 deletions test/compress/collapse_vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -7954,3 +7954,28 @@ mangleable_var: {
}
expect_stdout: "PASS"
}

issue_3884: {
options = {
collapse_vars: true,
evaluate: true,
reduce_vars: true,
side_effects: true,
toplevel: true,
unused: true,
}
input: {
var a = 100, b = 1;
{
a++ + a || a;
b <<= a;
}
console.log(a, b);
}
expect: {
var a = 100;
++a;
console.log(a, 32);
}
expect_stdout: "101 32"
}