aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-06-19 19:19:37 +0100
committerGitHub <noreply@github.com>2020-06-20 02:19:37 +0800
commite61bc34eb18972d95159a6c2b27b133ea370e41f (patch)
tree8e60b1671507ddee40c12388998e777efe012518
parent8b2cfd45fa8dd4f01d9535ad43bc37ce4953e78d (diff)
downloadtracifyjs-e61bc34eb18972d95159a6c2b27b133ea370e41f.tar.gz
tracifyjs-e61bc34eb18972d95159a6c2b27b133ea370e41f.zip
fix corner case in `collapse_vars` (#4002)
fixes #4001
-rw-r--r--lib/compress.js2
-rw-r--r--test/compress/ie8.js34
2 files changed, 34 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js
index b312c64d..0e11ba96 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1500,7 +1500,6 @@ merge(Compressor.prototype, {
can_replace = false;
var after = stop_after;
var if_hit = stop_if_hit;
- var rhs_fn = scan_rhs;
for (var i = 0; !abort && i < fn.body.length; i++) {
var stat = fn.body[i];
if (stat instanceof AST_Return) {
@@ -1509,7 +1508,6 @@ merge(Compressor.prototype, {
}
stat.transform(scanner);
}
- scan_rhs = rhs_fn;
stop_if_hit = if_hit;
stop_after = after;
can_replace = replace;
diff --git a/test/compress/ie8.js b/test/compress/ie8.js
index c0049766..df06c625 100644
--- a/test/compress/ie8.js
+++ b/test/compress/ie8.js
@@ -2559,3 +2559,37 @@ issue_3999: {
"1",
]
}
+
+issue_4001: {
+ options = {
+ collapse_vars: true,
+ ie8: true,
+ inline: true,
+ reduce_vars: true,
+ sequences: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ console.log(function(a) {
+ function f() {
+ return a;
+ var b;
+ }
+ var c = f();
+ (function g() {
+ c[42];
+ f;
+ })();
+ (function a() {});
+ }(42));
+ }
+ expect: {
+ function f() {
+ return a;
+ }
+ var a;
+ console.log((a = 42, void f()[42], void function a() {}));
+ }
+ expect_stdout: "undefined"
+}