fix escape analysis on || and &&

fixes #2598
This commit is contained in:
alexlamsl 2017-12-15 19:11:03 +08:00
parent 092d9affb8
commit 52fd938811
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"
}