aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-12-22 23:01:50 +0000
committerGitHub <noreply@github.com>2020-12-23 07:01:50 +0800
commitcb4a02949e14a8ffad88c327204f016407218ce9 (patch)
treeedac127ab6f870595e7146f5b17c16f2eca9c870 /lib/compress.js
parentf85a206b9ed5b39726a2da39680056c09d3f9687 (diff)
downloadtracifyjs-cb4a02949e14a8ffad88c327204f016407218ce9.tar.gz
tracifyjs-cb4a02949e14a8ffad88c327204f016407218ce9.zip
fix corner case with `NaN` (#4437)
fixes #4436
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js28
1 files changed, 13 insertions, 15 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 81fe8866..38342326 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -9297,10 +9297,9 @@ merge(Compressor.prototype, {
OPT(AST_Infinity, function(self, compressor) {
var lhs = is_lhs(compressor.self(), compressor.parent());
if (lhs && is_atomic(lhs, self)) return self;
- if (compressor.option("keep_infinity")
- && !(lhs && !is_atomic(lhs, self))
- && !find_scope(compressor).find_variable("Infinity"))
+ if (compressor.option("keep_infinity") && !lhs && !find_scope(compressor).find_variable("Infinity")) {
return self;
+ }
return make_node(AST_Binary, self, {
operator: "/",
left: make_node(AST_Number, self, {
@@ -9314,18 +9313,17 @@ merge(Compressor.prototype, {
OPT(AST_NaN, function(self, compressor) {
var lhs = is_lhs(compressor.self(), compressor.parent());
- if (lhs && !is_atomic(lhs, self) || find_scope(compressor).find_variable("NaN")) {
- return make_node(AST_Binary, self, {
- operator: "/",
- left: make_node(AST_Number, self, {
- value: 0
- }),
- right: make_node(AST_Number, self, {
- value: 0
- })
- });
- }
- return self;
+ if (lhs && is_atomic(lhs, self)) return self;
+ if (!lhs && !find_scope(compressor).find_variable("NaN")) return self;
+ return make_node(AST_Binary, self, {
+ operator: "/",
+ left: make_node(AST_Number, self, {
+ value: 0
+ }),
+ right: make_node(AST_Number, self, {
+ value: 0
+ })
+ });
});
function is_reachable(self, defs) {