Fix codegen for when comments_before is undefined.

Fix #333
This commit is contained in:
Mihai Bazon
2013-10-28 09:39:29 +02:00
parent b47f7b76b9
commit 0358e376f0
2 changed files with 5 additions and 5 deletions

View File

@@ -251,7 +251,6 @@ async.eachLimit(files, 1, function (file, cb) {
else if (ARGS.acorn) { else if (ARGS.acorn) {
TOPLEVEL = acorn.parse(code, { TOPLEVEL = acorn.parse(code, {
locations : true, locations : true,
trackComments : true,
sourceFile : file, sourceFile : file,
program : TOPLEVEL program : TOPLEVEL
}); });

View File

@@ -378,14 +378,15 @@ function OutputStream(options) {
var start = self.start; var start = self.start;
if (start && !start._comments_dumped) { if (start && !start._comments_dumped) {
start._comments_dumped = true; 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 // XXX: ugly fix for https://github.com/mishoo/UglifyJS2/issues/112
// if this node is `return` or `throw`, we cannot allow comments before // if this node is `return` or `throw`, we cannot allow comments before
// the returned or thrown value. // the returned or thrown value.
if (self instanceof AST_Exit && if (self instanceof AST_Exit && self.value
self.value && self.value.start.comments_before.length > 0) { && self.value.start.comments_before
comments = (comments || []).concat(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 = []; self.value.start.comments_before = [];
} }