aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-12-11 20:45:35 +0000
committerGitHub <noreply@github.com>2020-12-12 04:45:35 +0800
commit58dff9ada3adf21dbe7d8d205e76cfbd48b8619a (patch)
tree1d2e8cd46c8ca4f335a2f9271b3fb0f5ec255ff0
parent4fdec765bc71ad2654175442dfacd82fde07a863 (diff)
downloadtracifyjs-58dff9ada3adf21dbe7d8d205e76cfbd48b8619a.tar.gz
tracifyjs-58dff9ada3adf21dbe7d8d205e76cfbd48b8619a.zip
fix corner cases in `unused` & `varify` (#4368)
fixes #4365
-rw-r--r--lib/compress.js2
-rw-r--r--test/compress/const.js28
2 files changed, 29 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 27b080bb..cc601bfb 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -7284,7 +7284,7 @@ merge(Compressor.prototype, {
});
function is_safe_lexical(def) {
- return def.orig.length < (def.orig[0] instanceof AST_SymbolLambda ? 3 : 2);
+ return def.name != "arguments" && def.orig.length < (def.orig[0] instanceof AST_SymbolLambda ? 3 : 2);
}
function may_overlap(compressor, def) {
diff --git a/test/compress/const.js b/test/compress/const.js
index c269f8c0..4eea1977 100644
--- a/test/compress/const.js
+++ b/test/compress/const.js
@@ -1347,3 +1347,31 @@ issue_4305_2: {
}
expect_stdout: true
}
+
+issue_4365_1: {
+ options = {
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ const arguments = 42;
+ }
+ expect: {
+ const arguments = 42;
+ }
+ expect_stdout: true
+}
+
+issue_4365_2: {
+ options = {
+ toplevel: true,
+ varify: true,
+ }
+ input: {
+ const arguments = 42;
+ }
+ expect: {
+ const arguments = 42;
+ }
+ expect_stdout: true
+}