fix corner case in collapse_vars (#4071)

fixes #4070
This commit is contained in:
Alex Lam S.L
2020-08-25 10:23:36 +01:00
committed by GitHub
parent 1caf7c7bd2
commit a31c27c7cf
2 changed files with 23 additions and 1 deletions

View File

@@ -1286,7 +1286,7 @@ merge(Compressor.prototype, {
col: node.start.col
});
if (candidate instanceof AST_UnaryPostfix) {
lhs.definition().fixed = false;
if (lhs instanceof AST_SymbolRef) lhs.definition().fixed = false;
return make_node(AST_UnaryPrefix, candidate, candidate);
}
if (candidate instanceof AST_VarDef) {

View File

@@ -8538,3 +8538,25 @@ issue_4051: {
}
expect_stdout: "undefined"
}
issue_4070: {
options = {
collapse_vars: true,
pure_getters: "strict",
reduce_vars: true,
}
input: {
console.log(function f() {
function g() {}
g.p++;
return f.p = g.p;
}());
}
expect: {
console.log(function f() {
function g() {}
return f.p = ++g.p;
}());
}
expect_stdout: "NaN"
}