From 841d0ce331062a039f0222b4688ca4c16cb55f86 Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Sun, 12 Sep 2021 21:14:11 -0400 Subject: [PATCH] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fábio Santos --- lib/compress/evaluate.js | 2 +- lib/compress/inference.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/compress/evaluate.js b/lib/compress/evaluate.js index efff3e02a..4c4453375 100644 --- a/lib/compress/evaluate.js +++ b/lib/compress/evaluate.js @@ -83,7 +83,7 @@ function def_eval(node, func) { } // Used to propagate a nullish short-circuit signal upwards through the chain. -const nullish = {}; +const nullish = Symbol("This AST_Chain is nullish"); // If the node has been successfully reduced to a constant, // then its value is returned; otherwise the element itself diff --git a/lib/compress/inference.js b/lib/compress/inference.js index 2880cd87f..5a9e9d226 100644 --- a/lib/compress/inference.js +++ b/lib/compress/inference.js @@ -249,7 +249,7 @@ function is_nullish_shortcircuit(node, compressor) { || is_nullish_shortcircuit(node.expression, compressor) ); } - if (node instanceof AST_Chain) return is_nullish_shortcircuit(node.expression); + if (node instanceof AST_Chain) return is_nullish_shortcircuit(node.expression, compressor); return false; } @@ -440,7 +440,7 @@ export function is_nullish(node, compressor) { return any(this.body, compressor); }); def_may_throw(AST_Call, function(compressor) { - if (is_nullish(this.expression, compressor)) return false; + if (is_nullish(this, compressor)) return false; if (any(this.args, compressor)) return true; if (this.is_callee_pure(compressor)) return false; if (this.expression.may_throw(compressor)) return true;