aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-12-08 17:41:10 +0000
committerGitHub <noreply@github.com>2020-12-09 01:41:10 +0800
commit046bbde9d44a131ec60952e369ec4b22b9718def (patch)
tree87980753d84fb149ec8ce116671f3ec67ff08cb4
parentfea9da9866478388dcb6f11d4a792d9aea4a23cd (diff)
downloadtracifyjs-046bbde9d44a131ec60952e369ec4b22b9718def.tar.gz
tracifyjs-046bbde9d44a131ec60952e369ec4b22b9718def.zip
fix corner case in `keep_fargs` & `reduce_vars` (#4354)
fixes #4353
-rw-r--r--lib/compress.js1
-rw-r--r--test/compress/keep_fargs.js34
2 files changed, 35 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 144a5334..4da13758 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -904,6 +904,7 @@ merge(Compressor.prototype, {
reset_variables(tw, compressor, fn);
descend();
pop(tw);
+ if (fn.name) mark_escaped(tw, fn.name.definition(), fn, fn.name, fn, 0, 1);
walk_defuns(tw, fn);
}
return true;
diff --git a/test/compress/keep_fargs.js b/test/compress/keep_fargs.js
index 7141a410..8d6c5c99 100644
--- a/test/compress/keep_fargs.js
+++ b/test/compress/keep_fargs.js
@@ -1452,3 +1452,37 @@ issue_3619: {
}
expect_stdout: "PASS"
}
+
+issue_4353_1: {
+ options = {
+ keep_fargs: "strict",
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ console.log(function f(a) {}.length);
+ }
+ expect: {
+ console.log(function(a) {}.length);
+ }
+ expect_stdout: "1"
+}
+
+issue_4353_2: {
+ options = {
+ keep_fargs: "strict",
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ (function f(a) {
+ while (console.log("PASS"));
+ })();
+ }
+ expect: {
+ (function() {
+ while (console.log("PASS"));
+ })();
+ }
+ expect_stdout: "PASS"
+}