diff --git a/lib/compress.js b/lib/compress.js index 79e7d4d2..e172a83e 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2314,13 +2314,21 @@ merge(Compressor.prototype, { return make_node(AST_For, self, { body: self.body }); - } else if (compressor.option("dead_code") && self instanceof AST_While) { + } + if (compressor.option("dead_code") && self instanceof AST_While) { var a = []; extract_declarations_from_unreachable_code(compressor, self.body, a); return make_node(AST_BlockStatement, self, { body: a }); - } else { - cond = make_node_from_constant(cond, self.condition).transform(compressor); - self.condition = best_of_expression(cond, self.condition); + } + if (self instanceof AST_Do) { + var has_loop_control = false; + var tw = new TreeWalker(function(node) { + if (node instanceof AST_Scope || has_loop_control) return true; + if (node instanceof AST_LoopControl && tw.loopcontrol_target(node.label) === self) + return has_loop_control = true; + }); + self.walk(tw); + if (!has_loop_control) return self.body; } } if (self instanceof AST_While) { diff --git a/test/compress/loops.js b/test/compress/loops.js index c8d77840..5ca870d1 100644 --- a/test/compress/loops.js +++ b/test/compress/loops.js @@ -215,8 +215,7 @@ evaluate: { a(); for(;;) c(); - // rule disabled due to issue_1532 - do d(); while (false); + d(); } }