diff options
-rw-r--r-- | lib/compress.js | 47 | ||||
-rw-r--r-- | test/compress/yields.js | 15 |
2 files changed, 34 insertions, 28 deletions
diff --git a/lib/compress.js b/lib/compress.js index 9e9f15f6..591f28a8 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -4466,34 +4466,6 @@ merge(Compressor.prototype, { def(AST_Statement, function() { throw new Error("Cannot negate a statement"); }); - def(AST_Arrow, function() { - return basic_negation(this); - }); - def(AST_AsyncArrow, function() { - return basic_negation(this); - }); - def(AST_AsyncFunction, function() { - return basic_negation(this); - }); - def(AST_Function, function() { - return basic_negation(this); - }); - def(AST_UnaryPrefix, function() { - if (this.operator == "!") - return this.expression; - return basic_negation(this); - }); - def(AST_Sequence, function(compressor) { - var expressions = this.expressions.slice(); - expressions.push(expressions.pop().negate(compressor)); - return make_sequence(this, expressions); - }); - def(AST_Conditional, function(compressor, first_in_statement) { - var self = this.clone(); - self.consequent = self.consequent.negate(compressor); - self.alternative = self.alternative.negate(compressor); - return best(this, self, first_in_statement); - }); def(AST_Binary, function(compressor, first_in_statement) { var self = this.clone(), op = this.operator; if (compressor.option("unsafe_comps")) { @@ -4522,6 +4494,25 @@ merge(Compressor.prototype, { } return basic_negation(this); }); + def(AST_Conditional, function(compressor, first_in_statement) { + var self = this.clone(); + self.consequent = self.consequent.negate(compressor); + self.alternative = self.alternative.negate(compressor); + return best(this, self, first_in_statement); + }); + def(AST_LambdaExpression, function() { + return basic_negation(this); + }); + def(AST_Sequence, function(compressor) { + var expressions = this.expressions.slice(); + expressions.push(expressions.pop().negate(compressor)); + return make_sequence(this, expressions); + }); + def(AST_UnaryPrefix, function() { + if (this.operator == "!") + return this.expression; + return basic_negation(this); + }); })(function(node, func) { node.DEFMETHOD("negate", function(compressor, first_in_statement) { return func.call(this, compressor, first_in_statement); diff --git a/test/compress/yields.js b/test/compress/yields.js index 2c06a4ac..2d29c9b6 100644 --- a/test/compress/yields.js +++ b/test/compress/yields.js @@ -587,3 +587,18 @@ issue_4618: { expect_stdout: "function" node_version: ">=4" } + +issue_4623: { + options = { + conditionals: true, + } + input: { + if (console ? function*() {} : 0) + console.log("PASS"); + } + expect: { + (console ? function*() {} : 0) && console.log("PASS"); + } + expect_stdout: "PASS" + node_version: ">=4" +} |