From 719a8fd10256da8c7a5d28d0125fefdfff1ba187 Mon Sep 17 00:00:00 2001 From: Mihai Bazon Date: Tue, 5 Feb 2013 19:10:33 +0200 Subject: [PATCH] Ugly hack to print comments before return/throw statements Close #112 --- lib/output.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/output.js b/lib/output.js index cafb28fb..5e668201 100644 --- a/lib/output.js +++ b/lib/output.js @@ -375,6 +375,16 @@ function OutputStream(options) { if (start && !start._comments_dumped) { start._comments_dumped = true; 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); + self.value.start.comments_before = []; + } + if (c.test) { comments = comments.filter(function(comment){ return c.test(comment.value); -- 2.34.1