Fix negate_iife regression #1254
authorkzc <zaxxon2011@gmail.com>
Wed, 17 Aug 2016 01:54:54 +0000 (21:54 -0400)
committerkzc <zaxxon2011@gmail.com>
Wed, 17 Aug 2016 05:29:34 +0000 (01:29 -0400)
lib/output.js
test/compress/negate-iife.js

index 801f751..f1e0c2f 100644 (file)
@@ -531,6 +531,8 @@ function OutputStream(options) {
     });
 
     PARENS([ AST_Unary, AST_Undefined ], function(output){
+        if (this.expression instanceof AST_Call)
+            return false;
         var p = output.parent();
         return p instanceof AST_PropAccess && p.expression === this
             || p instanceof AST_Call && p.expression === this;
index b73ff54..aa95d95 100644 (file)
@@ -130,3 +130,31 @@ negate_iife_issue_1073: {
         }(7))();
     }
 }
+
+issue_1254_negate_iife_false: {
+    options = {
+        negate_iife: false,
+    }
+    input: {
+        (function() {
+            return function() {
+                console.log('test')
+            };
+        })()();
+    }
+    expect_exact: '(function(){return function(){console.log("test")}})()();'
+}
+
+issue_1254_negate_iife_true: {
+    options = {
+        negate_iife: true,
+    }
+    input: {
+        (function() {
+            return function() {
+                console.log('test')
+            };
+        })()();
+    }
+    expect_exact: '!function(){return function(){console.log("test")}}()();'
+}