aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-07-21 09:17:02 +0100
committeralexlamsl <alexlamsl@gmail.com>2020-07-21 17:22:18 +0800
commitcd671221c59feead948b13b024695dc04015fde6 (patch)
tree4f48fda50ae34452fb3113b94e705b3659f31e2b
parentbce3919748b1ece4d98625fee450f6096d7bb849 (diff)
downloadtracifyjs-cd671221c59feead948b13b024695dc04015fde6.tar.gz
tracifyjs-cd671221c59feead948b13b024695dc04015fde6.zip
fix corner case in `ie8` & `reduce_vars` (#4020)
fixes #4019
-rw-r--r--lib/compress.js1
-rw-r--r--test/compress/drop-unused.js2
-rw-r--r--test/compress/ie8.js27
3 files changed, 29 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 8ea5d8c9..1da49955 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -894,6 +894,7 @@ merge(Compressor.prototype, {
d.assignments++;
var fixed = d.fixed;
if (safe_to_read(tw, d) && safe_to_assign(tw, d)) {
+ if (d.single_use) d.single_use = false;
push_ref(d, exp);
mark(tw, d);
d.fixed = function() {
diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js
index 26721755..ee06199d 100644
--- a/test/compress/drop-unused.js
+++ b/test/compress/drop-unused.js
@@ -1729,7 +1729,7 @@ chained_3: {
}
expect: {
console.log(function(a, b) {
- var c = 2;
+ var c = b;
b++;
return c;
}(0, 2));
diff --git a/test/compress/ie8.js b/test/compress/ie8.js
index 2115dbc6..8ed23102 100644
--- a/test/compress/ie8.js
+++ b/test/compress/ie8.js
@@ -2634,3 +2634,30 @@ issue_4015: {
}
expect_stdout: "1"
}
+
+issue_4019: {
+ options = {
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ mangle = {
+ ie8: true,
+ toplevel: true,
+ }
+ input: {
+ var a = function() {
+ try {
+ console.log("FAIL");
+ } catch (b) {}
+ }, a = (console.log(a.length), ++a);
+ }
+ expect: {
+ var o = function() {
+ try {
+ console.log("FAIL");
+ } catch (o) {}
+ }, o = (console.log(o.length), ++o);
+ }
+ expect_stdout: "0"
+}