Skip to content

Commit

Permalink
fix corner case in collapse_vars (#3885)
Browse files Browse the repository at this point in the history
fixes #3884
  • Loading branch information
alexlamsl committed May 11, 2020
1 parent bd2f53b commit ee7647d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/compress.js
Expand Up @@ -1243,6 +1243,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
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"
}

0 comments on commit ee7647d

Please sign in to comment.