aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-05-14 18:49:46 +0100
committerGitHub <noreply@github.com>2021-05-15 01:49:46 +0800
commit2cff7c94e843e72dee1adf6c826a190f0e156441 (patch)
tree203b9086e8f327b4189e39acd51346b1f395c40d /test
parent75760481184c6d63595f8f7c3456b664d221abb5 (diff)
downloadtracifyjs-2cff7c94e843e72dee1adf6c826a190f0e156441.tar.gz
tracifyjs-2cff7c94e843e72dee1adf6c826a190f0e156441.zip
fix corner case in `reduce_vars` (#4934)
fixes #4933
Diffstat (limited to 'test')
-rw-r--r--test/compress/varify.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/compress/varify.js b/test/compress/varify.js
index f60c5474..75d50e6d 100644
--- a/test/compress/varify.js
+++ b/test/compress/varify.js
@@ -523,3 +523,55 @@ default_init: {
expect_stdout: "PASS"
node_version: ">=4"
}
+
+issue_4933_1: {
+ options = {
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ varify: true,
+ }
+ input: {
+ console.log(f());
+ function f() {
+ var a;
+ for (console in a = [ f ]) {
+ const b = a;
+ }
+ }
+ }
+ expect: {
+ console.log(function f() {
+ var a;
+ for (console in a = [ f ]) {
+ const b = a;
+ }
+ }());
+ }
+ expect_stdout: "undefined"
+}
+
+issue_4933_2: {
+ options = {
+ passes: 2,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ varify: true,
+ }
+ input: {
+ console.log(f());
+ function f() {
+ var a;
+ for (console in a = [ f ]) {
+ const b = a;
+ }
+ }
+ }
+ expect: {
+ console.log(function f() {
+ for (console in [ f ]);
+ }());
+ }
+ expect_stdout: "undefined"
+}