aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-05-25 17:12:31 +0100
committerGitHub <noreply@github.com>2021-05-26 00:12:31 +0800
commiteff45eac0ee284a113d1b587263fcef8e397daa3 (patch)
tree78fa26017d9c9e26f9798a34c77c3bfb4c07f0c9
parent1e787c556b916644e8ba2fc36fce024001f00ff8 (diff)
downloadtracifyjs-eff45eac0ee284a113d1b587263fcef8e397daa3.tar.gz
tracifyjs-eff45eac0ee284a113d1b587263fcef8e397daa3.zip
fix corner case in `ie8` (#4963)
fixes #4962
-rw-r--r--lib/compress.js3
-rw-r--r--test/compress/classes.js53
2 files changed, 54 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js
index f683e874..08b0f0d1 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -5281,7 +5281,7 @@ merge(Compressor.prototype, {
if (member(def.scope, scopes)) return true;
if (scope && !def.redefined()) {
var scope_def = scope.find_variable(node.name);
- if (def.undeclared ? !scope_def : scope_def === def) {
+ if (scope_def ? scope_def === def : def.undeclared) {
result = "f";
return true;
}
@@ -7637,7 +7637,6 @@ merge(Compressor.prototype, {
}).init_vars(node),
}));
exprs = [ node ];
-
}
if (values) exprs.push(make_node(AST_Call, this, {
expression: make_node(AST_Arrow, this, {
diff --git a/test/compress/classes.js b/test/compress/classes.js
index 69d7047e..11dc801f 100644
--- a/test/compress/classes.js
+++ b/test/compress/classes.js
@@ -1590,3 +1590,56 @@ issue_4951_2: {
expect_stdout: "PASS"
node_version: ">=14.6"
}
+
+issue_4962_1: {
+ options = {
+ ie8: true,
+ inline: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ (function() {
+ function f() {
+ while (console.log(typeof g));
+ }
+ class A {
+ static p = f();
+ }
+ })(function g() {});
+ }
+ expect: {
+ (function g() {}),
+ void function() {
+ while (console.log(typeof g));
+ }();
+ }
+ expect_stdout: "undefined"
+ node_version: ">=12"
+}
+
+issue_4962_2: {
+ options = {
+ ie8: true,
+ inline: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ console.log(function f() {}(function g() {
+ function h() {
+ f;
+ }
+ class A {
+ static p = h();
+ }
+ }, typeof g));
+ }
+ expect: {
+ console.log(function f() {}(function g() {
+ f;
+ }));
+ }
+ expect_stdout: "undefined"
+ node_version: ">=12"
+}