diff --git a/lib/compress.js b/lib/compress.js index 275e9ee034..b85bd8bb02 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -12119,7 +12119,11 @@ Compressor.prototype.compress = function(node) { var exprs = []; if (self.left.evaluate(compressor) instanceof AST_Node) exprs.push(self.left); if (self.right.evaluate(compressor) instanceof AST_Node) exprs.push(self.right); - if (exprs.length < 2) { + switch (exprs.length) { + case 0: + return make_node(AST_True, self).optimize(compressor); + case 1: + exprs[0] = exprs[0].clone(); exprs.push(make_node(AST_True, self)); return make_sequence(self, exprs).optimize(compressor); } diff --git a/test/compress/functions.js b/test/compress/functions.js index 26d9d00c30..7c4742257a 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -8968,3 +8968,32 @@ issue_5851_2: { "foo", ] } + +issue_5885: { + options = { + booleans: true, + evaluate: true, + inline: true, + reduce_vars: true, + side_effects: true, + toplevel: true, + unused: true, + } + input: { + var a; + f(); + function f() { + return ++a + "foo"; + } + console.log(a = f()); + } + expect: { + var a; + f(); + function f() { + return ++a + "foo"; + } + console.log(a = f()); + } + expect_stdout: "NaNfoo" +}