aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-05-22 02:56:35 +0100
committerGitHub <noreply@github.com>2020-05-22 09:56:35 +0800
commit75c5b6029be45c831ea01e9a5396909a969c7789 (patch)
tree4bda39e64a222dfe4da4a1532c94a6444c16bb22
parentfa14a9cfcd8d766887654b8b6da727489077033a (diff)
downloadtracifyjs-75c5b6029be45c831ea01e9a5396909a969c7789.tar.gz
tracifyjs-75c5b6029be45c831ea01e9a5396909a969c7789.zip
fix corner case in `ie8` & `reduce_vars` (#3919)
fixes #3918
-rw-r--r--lib/compress.js2
-rw-r--r--test/compress/ie8.js33
2 files changed, 35 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 17eeb87c..02b18adf 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -7515,6 +7515,8 @@ merge(Compressor.prototype, {
scope.inlined = true;
} while (scope = scope.parent_scope);
}
+ } else if (compressor.option("ie8") && fixed.name && def !== fixed.name.definition()) {
+ single_use = false;
}
if (single_use) fixed.parent_scope = self.scope;
} else if (!fixed || !fixed.is_constant_expression()) {
diff --git a/test/compress/ie8.js b/test/compress/ie8.js
index 68ccab17..e11e3651 100644
--- a/test/compress/ie8.js
+++ b/test/compress/ie8.js
@@ -2489,3 +2489,36 @@ issue_3889: {
}
expect_stdout: "undefined"
}
+
+issue_3918: {
+ options = {
+ conditionals: true,
+ ie8: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ mangle = {
+ ie8: true,
+ }
+ input: {
+ if (console.log("PASS")) {
+ var a = function f() {
+ f.p;
+ try {
+ console.log("FAIL");
+ } catch (e) {}
+ }, b = a;
+ }
+ }
+ expect: {
+ var a;
+ console.log("PASS") && (a = function f() {
+ f.p;
+ try {
+ console.log("FAIL");
+ } catch (o) {}
+ }, a);
+ }
+ expect_stdout: "PASS"
+}