aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2019-11-09 00:53:15 +0800
committerGitHub <noreply@github.com>2019-11-09 00:53:15 +0800
commit5045e140b18485132b533c4ee52a18f97f3bf6f9 (patch)
tree9ba7c052a209165034e19999fa03705a87acf568 /lib
parent10648c9af66364697f0f51219b0497fdfcb6dd34 (diff)
downloadtracifyjs-5045e140b18485132b533c4ee52a18f97f3bf6f9.tar.gz
tracifyjs-5045e140b18485132b533c4ee52a18f97f3bf6f9.zip
fix corner case in `conditionals` (#3577)
fixes #3576
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js15
1 files changed, 4 insertions, 11 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 43ee1126..26d17295 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -6673,7 +6673,7 @@ merge(Compressor.prototype, {
&& alt_tail instanceof AST_Assign
&& seq_tail.operator == alt_tail.operator
&& seq_tail.left.equivalent_to(alt_tail.left)
- && (is_eq && !seq_tail.left.has_side_effects(compressor)
+ && (is_eq && seq_tail.left instanceof AST_SymbolRef
|| !condition.has_side_effects(compressor)
&& can_shift_lhs_of_tail(consequent)
&& can_shift_lhs_of_tail(alternative))) {
@@ -6842,16 +6842,9 @@ merge(Compressor.prototype, {
}
function can_shift_lhs_of_tail(node) {
- if (node === node.tail_node()) return true;
- var exprs = node.expressions;
- for (var i = exprs.length - 1; --i >= 0;) {
- var expr = exprs[i];
- if (!(expr instanceof AST_Assign) && expr.has_side_effects(compressor)
- || expr.operator != "="
- || expr.left.has_side_effects(compressor)
- || expr.right.has_side_effects(compressor)) return false;
- }
- return true;
+ return node === node.tail_node() || all(node.expressions.slice(0, -1), function(expr) {
+ return !expr.has_side_effects(compressor);
+ });
}
function pop_lhs(node) {