From 52cc21d9995fcda6e78e0514dab2bb67e9b1cb91 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Fri, 30 Jun 2017 11:17:58 +0800 Subject: [PATCH] remove extraneous `!` before `AST_Arrow` (#2185) --- lib/compress.js | 10 +++++----- test/compress/arrow.js | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/compress.js b/lib/compress.js index eef43396..1eb6bbff 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -561,8 +561,8 @@ merge(Compressor.prototype, { return orig.length == 1 && orig[0] instanceof AST_SymbolLambda; }); - function is_func_expr(node, traditional) { - return node instanceof AST_Function || !traditional && node instanceof AST_Arrow; + function is_func_expr(node) { + return node instanceof AST_Arrow || node instanceof AST_Function; } function is_lhs_read_only(lhs) { @@ -706,9 +706,9 @@ merge(Compressor.prototype, { return x; }; - function is_iife_call(node, traditional) { + function is_iife_call(node) { if (node instanceof AST_Call && !(node instanceof AST_New)) { - return is_func_expr(node.expression, traditional) || is_iife_call(node.expression); + return node.expression instanceof AST_Function || is_iife_call(node.expression); } return false; } @@ -3452,7 +3452,7 @@ merge(Compressor.prototype, { } if (compressor.option("negate_iife") && compressor.parent() instanceof AST_SimpleStatement - && is_iife_call(self, true)) { + && is_iife_call(self)) { return self.negate(compressor, true); } var ev = self.evaluate(compressor); diff --git a/test/compress/arrow.js b/test/compress/arrow.js index 02b39571..99376da2 100644 --- a/test/compress/arrow.js +++ b/test/compress/arrow.js @@ -312,7 +312,7 @@ issue_2105_1: { }); } expect: { - !void (() => { + void (() => { var quux = () => { console.log("PASS"); }; @@ -357,7 +357,7 @@ issue_2105_2: { }); } expect: { - !void (() => { + void (() => { var quux = () => { console.log("PASS"); }; @@ -528,7 +528,7 @@ issue_2084: { } expect: { var c = 0; - !((c) => { + ((c) => { c = 1 + c, c = 1 + (c = 0), 0 !== 23..toString() && (c = 1 + c);