fix corner case in booleans & inline (#5229)

fixes #5228
This commit is contained in:
Alex Lam S.L
2021-12-21 15:46:20 +00:00
committed by GitHub
parent ba42cbad3f
commit 343bf6d7a5
2 changed files with 28 additions and 0 deletions

View File

@@ -12789,6 +12789,7 @@ Compressor.prototype.compress = function(node) {
var inlined = self.expression.try_inline(compressor, scope); var inlined = self.expression.try_inline(compressor, scope);
if (!inlined) return; if (!inlined) return;
scan_local_returns(inlined, function(node) { scan_local_returns(inlined, function(node) {
node.in_bool = false;
var value = node.value; var value = node.value;
if (op == "void") { if (op == "void") {
if (!value) return; if (!value) return;

View File

@@ -697,3 +697,30 @@ issue_5041_2: {
} }
expect_stdout: "PASS" 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"
}