fix corner case in collapse_vars

fixes #3884
This commit is contained in:
alexlamsl 2020-05-12 02:21:40 +08:00
parent 2b24dc25fb
commit 6c2069385f
2 changed files with 26 additions and 0 deletions

View File

@ -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) {

View File

@ -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"
}