fix escape analysis on || and && (#2600)

fixes #2598
This commit is contained in:
Alex Lam S.L
2017-12-15 19:48:14 +08:00
committed by GitHub
parent 7d6907cb99
commit db902af4c6
2 changed files with 25 additions and 0 deletions

View File

@@ -674,6 +674,7 @@ merge(Compressor.prototype, {
d.escaped = true;
return;
} else if (parent instanceof AST_Array
|| parent instanceof AST_Binary && lazy_op(parent.operator)
|| parent instanceof AST_Conditional && node !== parent.condition
|| parent instanceof AST_Sequence && node === parent.tail_node()) {
mark_escaped(d, scope, parent, parent, level + 1);

View File

@@ -4899,3 +4899,27 @@ do_while: {
}
expect_stdout: "PASS"
}
issue_2598: {
options = {
reduce_funcs: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
function f() {}
function g(a) {
return a || f;
}
console.log(g(false) === g(null));
}
expect: {
function f() {}
function g(a) {
return a || f;
}
console.log(g(false) === g(null));
}
expect_stdout: "true"
}