fix corner case in ie8 (#3543)

fixes #3542
This commit is contained in:
Alex Lam S.L
2019-10-28 23:54:27 +08:00
committed by GitHub
parent f38e31bd1e
commit 83fb8b4ca1
2 changed files with 23 additions and 1 deletions

View File

@@ -4238,7 +4238,7 @@ merge(Compressor.prototype, {
def(AST_Binary, function(compressor, first_in_statement) {
var right = this.right.drop_side_effect_free(compressor, first_in_statement);
if (!right) return this.left.drop_side_effect_free(compressor, first_in_statement);
if (lazy_op[this.operator]) {
if (lazy_op[this.operator] && !(right instanceof AST_Function)) {
var node = this;
if (right !== node.right) {
node = this.clone();

View File

@@ -2339,3 +2339,25 @@ issue_3523_rename_ie8_toplevel: {
}
expect_stdout: "PASS"
}
issue_3542: {
options = {
ie8: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var a = 0;
var b = a++;
var c = b && function a() {} || b;
console.log(a);
}
expect: {
var a = 0;
a++;
(function a() {});
console.log(a);
}
expect_stdout: "1"
}