Skip to content

Commit 5411360

Browse files
authored
fix corner case in if_return (#5711)
fixes #5710
1 parent 7edd10e commit 5411360

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

Diff for: lib/compress.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3536,7 +3536,7 @@ Compressor.prototype.compress = function(node) {
35363536
var declare_only, jump, merge_jump;
35373537
var in_iife = in_lambda && parent && parent.TYPE == "Call" && parent.expression === self;
35383538
var chain_if_returns = in_lambda && compressor.option("conditionals") && compressor.option("sequences");
3539-
var drop_return_void = !(in_try && in_try.bfinally && in_async_generator(in_lambda));
3539+
var drop_return_void = !(in_try && in_try.bfinally && in_async_generator(scope));
35403540
var multiple_if_returns = has_multiple_if_returns(statements);
35413541
for (var i = statements.length; --i >= 0;) {
35423542
var stat = statements[i];

Diff for: test/compress/yields.js

+37
Original file line numberDiff line numberDiff line change
@@ -2039,3 +2039,40 @@ issue_5707: {
20392039
expect_stdout: "PASS"
20402040
node_version: ">=6"
20412041
}
2042+
2043+
issue_5710: {
2044+
options = {
2045+
conditionals: true,
2046+
if_return: true,
2047+
}
2048+
input: {
2049+
(async function*() {
2050+
try {
2051+
switch (42) {
2052+
case 42:
2053+
{
2054+
if (console.log("PASS"))
2055+
return;
2056+
return null;
2057+
}
2058+
break;
2059+
}
2060+
} finally {}
2061+
})().next();
2062+
}
2063+
expect: {
2064+
(async function*() {
2065+
try {
2066+
switch (42) {
2067+
case 42:
2068+
if (console.log("PASS"))
2069+
return;
2070+
return null;
2071+
break;
2072+
}
2073+
} finally {}
2074+
})().next();
2075+
}
2076+
expect_stdout: "PASS"
2077+
node_version: ">=10"
2078+
}

0 commit comments

Comments
 (0)