aboutsummaryrefslogtreecommitdiff
path: root/test/compress/collapse_vars.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2019-10-24 01:13:57 +0800
committerGitHub <noreply@github.com>2019-10-24 01:13:57 +0800
commit0f7aa41e339b574ee0f67c093438d356a8a85477 (patch)
tree21ae6f719c7310c46e8e0edf2f099481a76aa756 /test/compress/collapse_vars.js
parent370c8e03855f17d73e8a0f75ae0b9b40e31e47e9 (diff)
downloadtracifyjs-0f7aa41e339b574ee0f67c093438d356a8a85477.tar.gz
tracifyjs-0f7aa41e339b574ee0f67c093438d356a8a85477.zip
fix corner case in `collapse_vars` (#3521)
fixes #3520
Diffstat (limited to 'test/compress/collapse_vars.js')
-rw-r--r--test/compress/collapse_vars.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index a793ef6c..5723f6d9 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -6258,3 +6258,41 @@ cond_sequence_return: {
}
expect_stdout: "2"
}
+
+issue_3520: {
+ options = {
+ collapse_vars: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ var a = 0;
+ var b = function(c) {
+ for (var i = 2; --i >= 0;) {
+ (function f() {
+ c = 0;
+ var i = void 0;
+ var f = f && f[i];
+ })();
+ a += b;
+ c && b++;
+ }
+ }(b = 1);
+ console.log(a);
+ }
+ expect: {
+ var a = 0;
+ var b = function(c) {
+ for (var i = 2; --i >= 0;) {
+ (function() {
+ c = 0;
+ var f = f && f[void 0];
+ })();
+ a += b;
+ c && b++;
+ }
+ }(b = 1);
+ console.log(a);
+ }
+ expect_stdout: "2"
+}