Skip to content

Commit 4bf9a4f

Browse files
authoredJul 30, 2024··
fix corner case in inline (#5896)
fixes #5895
1 parent 4b86eaf commit 4bf9a4f

File tree

2 files changed

+80
-1
lines changed

2 files changed

+80
-1
lines changed
 

‎lib/compress.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4094,7 +4094,7 @@ Compressor.prototype.compress = function(node) {
40944094
changed = true;
40954095
}
40964096
}
4097-
var loop = in_loop && in_try && in_try.bfinally ? "try" : in_loop;
4097+
var loop = in_loop && in_try ? "try" : in_loop;
40984098
for (; index >= 0; index--) {
40994099
var inlined = statements[index].try_inline(compressor, block_scope, true, loop);
41004100
if (!inlined) continue;

‎test/compress/functions.js

+79
Original file line numberDiff line numberDiff line change
@@ -8997,3 +8997,82 @@ issue_5885: {
89978997
}
89988998
expect_stdout: "NaNfoo"
89998999
}
9000+
9001+
issue_5895_1: {
9002+
options = {
9003+
inline: true,
9004+
unused: true,
9005+
}
9006+
input: {
9007+
(function() {
9008+
for (var a in [ 1, 2 ])
9009+
try {
9010+
return function() {
9011+
var b;
9012+
b[b = 42];
9013+
while (!console);
9014+
}();
9015+
} catch (e) {
9016+
console.log("foo");
9017+
}
9018+
})();
9019+
}
9020+
expect: {
9021+
(function() {
9022+
for (var a in [ 1, 2 ])
9023+
try {
9024+
b = void 0;
9025+
var b;
9026+
b[b = 42];
9027+
while (!console);
9028+
return;
9029+
} catch (e) {
9030+
console.log("foo");
9031+
}
9032+
})();
9033+
}
9034+
expect_stdout: [
9035+
"foo",
9036+
"foo",
9037+
]
9038+
}
9039+
9040+
issue_5895_2: {
9041+
options = {
9042+
inline: true,
9043+
unused: true,
9044+
}
9045+
input: {
9046+
(function() {
9047+
for (var a in [ 1, 2 ])
9048+
try {
9049+
return function() {
9050+
(function f(b) {
9051+
b[b = 42];
9052+
})();
9053+
while (!console);
9054+
}();
9055+
} catch (e) {
9056+
console.log("foo");
9057+
}
9058+
})();
9059+
}
9060+
expect: {
9061+
(function() {
9062+
for (var a in [ 1, 2 ])
9063+
try {
9064+
b = void 0;
9065+
void b[b = 42];
9066+
var b;
9067+
while (!console);
9068+
return;
9069+
} catch (e) {
9070+
console.log("foo");
9071+
}
9072+
})();
9073+
}
9074+
expect_stdout: [
9075+
"foo",
9076+
"foo",
9077+
]
9078+
}

0 commit comments

Comments
 (0)
Please sign in to comment.