fix corner case in evaluate (#3938)

fixes #3937
This commit is contained in:
Alex Lam S.L
2020-05-30 11:22:40 +01:00
committed by GitHub
parent 43498769f0
commit 0eb4577a82
2 changed files with 22 additions and 1 deletions

View File

@@ -3493,7 +3493,7 @@ merge(Compressor.prototype, {
var fixed = this.fixed_value(); var fixed = this.fixed_value();
if (!fixed) return this; if (!fixed) return this;
var value; var value;
if (member(fixed, cached)) { if (HOP(fixed, "_eval")) {
value = fixed._eval(); value = fixed._eval();
} else { } else {
this._eval = return_this; this._eval = return_this;

View File

@@ -2669,3 +2669,24 @@ issue_3935: {
} }
expect_stdout: "NaN" expect_stdout: "NaN"
} }
issue_3937: {
options = {
conditionals: true,
evaluate: true,
reduce_vars: true,
toplevel: true,
unsafe: true,
}
input: {
var a = 123;
(a++ + (b = a))[b] ? 0 ? a : b : 0 ? a : b;
console.log(a, b);
}
expect: {
var a = 123;
(a++ + (b = a))[b], 0, b;
console.log(a, b);
}
expect_stdout: "124 124"
}