aboutsummaryrefslogtreecommitdiff
path: root/test/compress/reduce_vars.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-10-07 15:01:39 +0100
committerGitHub <noreply@github.com>2020-10-07 22:01:39 +0800
commit9c0feb69e5cdd3d491c6b0600fc964a41a774710 (patch)
treedf6b2bb2d84ddc47661359a7e1ff5ec9c27eea1f /test/compress/reduce_vars.js
parentbc6e105174eb67547c2bd988899e4c4f2d8f6ada (diff)
downloadtracifyjs-9c0feb69e5cdd3d491c6b0600fc964a41a774710.tar.gz
tracifyjs-9c0feb69e5cdd3d491c6b0600fc964a41a774710.zip
fix corner case in `reduce_vars` (#4189)
fixes #4188
Diffstat (limited to 'test/compress/reduce_vars.js')
-rw-r--r--test/compress/reduce_vars.js66
1 files changed, 66 insertions, 0 deletions
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index 414d6646..ea3703c1 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -7535,3 +7535,69 @@ global_assign: {
}
expect_stdout: "PASS"
}
+
+issue_4188_1: {
+ options = {
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ (function() {
+ try {
+ while (A)
+ var a = function() {}, b = a;
+ } catch (a) {
+ console.log(function() {
+ return typeof a;
+ }(), typeof b);
+ }
+ })();
+ }
+ expect: {
+ (function() {
+ try {
+ while (A)
+ var a = function() {}, b = a;
+ } catch (a) {
+ console.log(function() {
+ return typeof a;
+ }(), typeof b);
+ }
+ })();
+ }
+ expect_stdout: "object undefined"
+}
+
+issue_4188_2: {
+ options = {
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ (function() {
+ try {
+ throw 42;
+ } catch (a) {
+ console.log(function() {
+ return typeof a;
+ }(), typeof b);
+ }
+ while (!console)
+ var a = function() {}, b = a;
+ })();
+ }
+ expect: {
+ (function() {
+ try {
+ throw 42;
+ } catch (a) {
+ console.log(function() {
+ return typeof a;
+ }(), typeof b);
+ }
+ while (!console)
+ var a = function() {}, b = a;
+ })();
+ }
+ expect_stdout: "number undefined"
+}