Skip to content

Commit

Permalink
fix corner case in booleans & inline (#5229)
Browse files Browse the repository at this point in the history
fixes #5228
  • Loading branch information
alexlamsl committed Dec 21, 2021
1 parent ba42cba commit 343bf6d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/compress.js
Expand Up @@ -12789,6 +12789,7 @@ Compressor.prototype.compress = function(node) {
var inlined = self.expression.try_inline(compressor, scope);
if (!inlined) return;
scan_local_returns(inlined, function(node) {
node.in_bool = false;
var value = node.value;
if (op == "void") {
if (!value) return;
Expand Down
27 changes: 27 additions & 0 deletions test/compress/booleans.js
Expand Up @@ -697,3 +697,30 @@ issue_5041_2: {
}
expect_stdout: "PASS"
}

issue_5228: {
options = {
booleans: true,
evaluate: true,
inline: true,
passes: 2,
}
input: {
console.log(function() {
return !function() {
do {
return null;
} while (console);
}();
}());
}
expect: {
console.log(function() {
do {
return !0;
} while (console);
return !0;
}());
}
expect_stdout: "true"
}

0 comments on commit 343bf6d

Please sign in to comment.