aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-05-17 22:52:24 +0100
committerGitHub <noreply@github.com>2021-05-18 05:52:24 +0800
commit254937754c2e3c33f934dcf7df619d8a46319a14 (patch)
tree2c31e19f7e47d4a3e50583b8a3fc7872397bdd9b /test/compress
parentae4dbcb5b96ddb2696de1d890e6a71b2445f7ec5 (diff)
downloadtracifyjs-254937754c2e3c33f934dcf7df619d8a46319a14.tar.gz
tracifyjs-254937754c2e3c33f934dcf7df619d8a46319a14.zip
fix corner case in `reduce_vars` (#4944)
fixes #4943
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/reduce_vars.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index c899fcf0..04d96b51 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -7662,3 +7662,63 @@ issue_4937: {
}
expect_stdout: "PASS"
}
+
+issue_4943_1: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ toplevel: true,
+ }
+ input: {
+ var a, b = 1;
+ (function f() {
+ a = "foo";
+ b-- && f();
+ console.log(a);
+ a = "bar";
+ })();
+ }
+ expect: {
+ var a, b = 1;
+ (function f() {
+ a = "foo";
+ b-- && f();
+ console.log(a);
+ a = "bar";
+ })();
+ }
+ expect_stdout: [
+ "foo",
+ "bar",
+ ]
+}
+
+issue_4943_2: {
+ options = {
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var a, b = 1;
+ (function f() {
+ a = "foo";
+ b-- && f();
+ console.log(a);
+ a = "bar";
+ })();
+ }
+ expect: {
+ var a, b = 1;
+ (function f() {
+ a = "foo";
+ b-- && f();
+ console.log(a);
+ a = "bar";
+ })();
+ }
+ expect_stdout: [
+ "foo",
+ "bar",
+ ]
+}