aborts(AST_If) returns the `if` node
authorMihai Bazon <mihai@bazon.net>
Tue, 6 Jan 2015 11:57:18 +0000 (13:57 +0200)
committerMihai Bazon <mihai@bazon.net>
Tue, 6 Jan 2015 12:01:35 +0000 (14:01 +0200)
Previously it returned the abort node from the alternative branch.  This is
not much use as it can be different from the one in the body
branch (i.e. return vs. throw) and can trick us into issues like #591.

Fix #591

lib/compress.js

index 345d8ad..83c3e6d 100644 (file)
@@ -950,7 +950,7 @@ merge(Compressor.prototype, {
         def(AST_BlockStatement, block_aborts);
         def(AST_SwitchBranch, block_aborts);
         def(AST_If, function(){
-            return this.alternative && aborts(this.body) && aborts(this.alternative);
+            return this.alternative && aborts(this.body) && aborts(this.alternative) && this;
         });
     })(function(node, func){
         node.DEFMETHOD("aborts", func);