Better fix for comments in AST_Exit
authorMihai Bazon <mihai@bazon.net>
Wed, 18 Dec 2013 13:54:12 +0000 (15:54 +0200)
committerMihai Bazon <mihai@bazon.net>
Wed, 18 Dec 2013 13:54:12 +0000 (15:54 +0200)
Close #374

lib/output.js

index 1ef92dd..9ed155b 100644 (file)
@@ -389,10 +389,16 @@ function OutputStream(options) {
                 //               and https://github.com/mishoo/UglifyJS2/issues/372
                 if (self instanceof AST_Exit && self.value) {
                     self.value.walk(new TreeWalker(function(node){
-                        if (node.start.comments_before) {
+                        if (node.start && node.start.comments_before) {
                             comments = comments.concat(node.start.comments_before);
                             node.start.comments_before = [];
                         }
+                        if (node instanceof AST_Function ||
+                            node instanceof AST_Array ||
+                            node instanceof AST_Object)
+                        {
+                            return true; // don't go inside.
+                        }
                     }));
                 }