Fix endless loop
authorMihai Bazon <mihai.bazon@gmail.com>
Mon, 16 Nov 2015 10:07:15 +0000 (12:07 +0200)
committerMihai Bazon <mihai.bazon@gmail.com>
Mon, 16 Nov 2015 10:08:24 +0000 (12:08 +0200)
Close #866

lib/compress.js

index c384e99..32833eb 100644 (file)
@@ -384,7 +384,12 @@ merge(Compressor.prototype, {
                             continue loop;
                         }
                         //---
-                        if (ret.length == 1 && in_lambda && ret[0] instanceof AST_SimpleStatement
+                        // XXX: what was the intention of this case?
+                        // if sequences is not enabled, this can lead to an endless loop (issue #866).
+                        // however, with sequences on this helps producing slightly better output for
+                        // the example code.
+                        if (compressor.option("sequences")
+                            && ret.length == 1 && in_lambda && ret[0] instanceof AST_SimpleStatement
                             && (!stat.alternative || stat.alternative instanceof AST_SimpleStatement)) {
                             CHANGED = true;
                             ret.push(make_node(AST_Return, ret[0], {