aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-02-20 03:13:15 +0000
committerGitHub <noreply@github.com>2021-02-20 11:13:15 +0800
commit8d668c2963c4322fea47009b057791c1a7caa612 (patch)
tree44d746bffd43a8cee09d060f3d08f3432ae4a272 /lib
parent5f60c1b830fec648974b3ea7cbd6f53a6bfd7c75 (diff)
downloadtracifyjs-8d668c2963c4322fea47009b057791c1a7caa612.tar.gz
tracifyjs-8d668c2963c4322fea47009b057791c1a7caa612.zip
fix corner case in `conditionals` & `side_effects` (#4669)
fixes #4668
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/compress.js b/lib/compress.js
index c3e315de..da30cee1 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -5788,15 +5788,12 @@ merge(Compressor.prototype, {
if (!in_use || node.left === sym && indexOf_assign(def, node) < 0) {
value = get_rhs(node);
if (node.write_only === true) {
- value = value.drop_side_effect_free(compressor) || make_node(AST_Number, node, {
- value: 0
- });
+ value = value.drop_side_effect_free(compressor)
+ || make_node(AST_Number, node, { value: 0 });
}
}
} else if (!in_use || node.expression === sym && indexOf_assign(def, node) < 0) {
- value = make_node(AST_Number, node, {
- value: 0
- });
+ value = make_node(AST_Number, node, { value: 0 });
}
if (value) {
if (parent instanceof AST_Sequence && parent.tail_node() !== node) {
@@ -7168,7 +7165,7 @@ merge(Compressor.prototype, {
assign = assign.clone();
assign.right = cond;
expressions = expressions.slice(0, -2);
- expressions.push(assign);
+ expressions.push(assign.drop_side_effect_free(compressor, first_in_statement));
}
return expressions === this.expressions ? this : make_sequence(this, expressions);
});