From 0358e376f04b5f67616d57ccfd0fafbe1b9a6979 Mon Sep 17 00:00:00 2001 From: Mihai Bazon Date: Mon, 28 Oct 2013 09:39:29 +0200 Subject: [PATCH] Fix codegen for when comments_before is undefined. Fix #333 --- bin/uglifyjs | 1 - lib/output.js | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/uglifyjs b/bin/uglifyjs index 90b71a20..b103cc3e 100755 --- a/bin/uglifyjs +++ b/bin/uglifyjs @@ -251,7 +251,6 @@ async.eachLimit(files, 1, function (file, cb) { else if (ARGS.acorn) { TOPLEVEL = acorn.parse(code, { locations : true, - trackComments : true, sourceFile : file, program : TOPLEVEL }); diff --git a/lib/output.js b/lib/output.js index e7f3f4dd..7eb685a0 100644 --- a/lib/output.js +++ b/lib/output.js @@ -378,14 +378,15 @@ function OutputStream(options) { var start = self.start; if (start && !start._comments_dumped) { start._comments_dumped = true; - var comments = start.comments_before; + var comments = start.comments_before || []; // XXX: ugly fix for https://github.com/mishoo/UglifyJS2/issues/112 // if this node is `return` or `throw`, we cannot allow comments before // the returned or thrown value. - if (self instanceof AST_Exit && - self.value && self.value.start.comments_before.length > 0) { - comments = (comments || []).concat(self.value.start.comments_before); + if (self instanceof AST_Exit && self.value + && self.value.start.comments_before + && self.value.start.comments_before.length > 0) { + comments = comments.concat(self.value.start.comments_before); self.value.start.comments_before = []; } -- 2.34.1