Skip to content

Commit

Permalink
fix corner case in if_return (#5711)
Browse files Browse the repository at this point in the history
fixes #5710
  • Loading branch information
alexlamsl committed Oct 13, 2022
1 parent 7edd10e commit 5411360
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compress.js
Expand Up @@ -3536,7 +3536,7 @@ Compressor.prototype.compress = function(node) {
var declare_only, jump, merge_jump;
var in_iife = in_lambda && parent && parent.TYPE == "Call" && parent.expression === self;
var chain_if_returns = in_lambda && compressor.option("conditionals") && compressor.option("sequences");
var drop_return_void = !(in_try && in_try.bfinally && in_async_generator(in_lambda));
var drop_return_void = !(in_try && in_try.bfinally && in_async_generator(scope));
var multiple_if_returns = has_multiple_if_returns(statements);
for (var i = statements.length; --i >= 0;) {
var stat = statements[i];
Expand Down
37 changes: 37 additions & 0 deletions test/compress/yields.js
Expand Up @@ -2039,3 +2039,40 @@ issue_5707: {
expect_stdout: "PASS"
node_version: ">=6"
}

issue_5710: {
options = {
conditionals: true,
if_return: true,
}
input: {
(async function*() {
try {
switch (42) {
case 42:
{
if (console.log("PASS"))
return;
return null;
}
break;
}
} finally {}
})().next();
}
expect: {
(async function*() {
try {
switch (42) {
case 42:
if (console.log("PASS"))
return;
return null;
break;
}
} finally {}
})().next();
}
expect_stdout: "PASS"
node_version: ">=10"
}

0 comments on commit 5411360

Please sign in to comment.