Skip to content

Commit eff45ea

Browse files
authored
fix corner case in ie8 (#4963)
fixes #4962
1 parent 1e787c5 commit eff45ea

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

lib/compress.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5281,7 +5281,7 @@ merge(Compressor.prototype, {
52815281
if (member(def.scope, scopes)) return true;
52825282
if (scope && !def.redefined()) {
52835283
var scope_def = scope.find_variable(node.name);
5284-
if (def.undeclared ? !scope_def : scope_def === def) {
5284+
if (scope_def ? scope_def === def : def.undeclared) {
52855285
result = "f";
52865286
return true;
52875287
}
@@ -7637,7 +7637,6 @@ merge(Compressor.prototype, {
76377637
}).init_vars(node),
76387638
}));
76397639
exprs = [ node ];
7640-
76417640
}
76427641
if (values) exprs.push(make_node(AST_Call, this, {
76437642
expression: make_node(AST_Arrow, this, {

test/compress/classes.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,3 +1590,56 @@ issue_4951_2: {
15901590
expect_stdout: "PASS"
15911591
node_version: ">=14.6"
15921592
}
1593+
1594+
issue_4962_1: {
1595+
options = {
1596+
ie8: true,
1597+
inline: true,
1598+
reduce_vars: true,
1599+
unused: true,
1600+
}
1601+
input: {
1602+
(function() {
1603+
function f() {
1604+
while (console.log(typeof g));
1605+
}
1606+
class A {
1607+
static p = f();
1608+
}
1609+
})(function g() {});
1610+
}
1611+
expect: {
1612+
(function g() {}),
1613+
void function() {
1614+
while (console.log(typeof g));
1615+
}();
1616+
}
1617+
expect_stdout: "undefined"
1618+
node_version: ">=12"
1619+
}
1620+
1621+
issue_4962_2: {
1622+
options = {
1623+
ie8: true,
1624+
inline: true,
1625+
reduce_vars: true,
1626+
unused: true,
1627+
}
1628+
input: {
1629+
console.log(function f() {}(function g() {
1630+
function h() {
1631+
f;
1632+
}
1633+
class A {
1634+
static p = h();
1635+
}
1636+
}, typeof g));
1637+
}
1638+
expect: {
1639+
console.log(function f() {}(function g() {
1640+
f;
1641+
}));
1642+
}
1643+
expect_stdout: "undefined"
1644+
node_version: ">=12"
1645+
}

0 commit comments

Comments
 (0)