aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-10-19 23:13:23 +0100
committerGitHub <noreply@github.com>2020-10-20 06:13:23 +0800
commit256950c2c0b4dc0c133fcc8aaf85f15579eb190f (patch)
tree6155f657d76471ecf34371b4a9b3949003690ae6
parent8ecaa40c6e7c9936476b22e994947982a40e0b50 (diff)
downloadtracifyjs-256950c2c0b4dc0c133fcc8aaf85f15579eb190f.tar.gz
tracifyjs-256950c2c0b4dc0c133fcc8aaf85f15579eb190f.zip
fix corner case in `ie8` (#4230)
fixes #4229
-rw-r--r--lib/scope.js1
-rw-r--r--test/compress/const.js20
-rw-r--r--test/compress/let.js31
3 files changed, 52 insertions, 0 deletions
diff --git a/lib/scope.js b/lib/scope.js
index 4abf4066..208633d0 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -294,6 +294,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
node.redef = true;
node.thedef = new_def;
node.reference(options);
+ if (node instanceof AST_SymbolConst || node instanceof AST_SymbolLet) new_def.orig.push(node);
});
if (old_def.lambda) new_def.lambda = true;
if (new_def.undeclared) self.variables.set(name, new_def);
diff --git a/test/compress/const.js b/test/compress/const.js
index 8bb9a94e..b20c4c59 100644
--- a/test/compress/const.js
+++ b/test/compress/const.js
@@ -1045,3 +1045,23 @@ issue_4225: {
}
expect_stdout: true
}
+
+issue_4229: {
+ options = {
+ ie8: true,
+ side_effects: true,
+ }
+ input: {
+ (function f() {
+ f;
+ const f = 42;
+ })();
+ }
+ expect: {
+ (function f() {
+ f;
+ const f = 42;
+ })();
+ }
+ expect_stdout: true
+}
diff --git a/test/compress/let.js b/test/compress/let.js
index 74e8fd81..c40ae9e3 100644
--- a/test/compress/let.js
+++ b/test/compress/let.js
@@ -840,3 +840,34 @@ issue_4225: {
expect_stdout: true
node_version: ">=4"
}
+
+issue_4229: {
+ options = {
+ ie8: true,
+ side_effects: true,
+ }
+ input: {
+ "use strict";
+ try {
+ (function f() {
+ f;
+ let f;
+ })();
+ } catch (e) {
+ console.log("PASS");
+ }
+ }
+ expect: {
+ "use strict";
+ try {
+ (function f() {
+ f;
+ let f;
+ })();
+ } catch (e) {
+ console.log("PASS");
+ }
+ }
+ expect_stdout: "PASS"
+ node_version: ">=4"
+}