aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-02-05 01:03:51 +0000
committerGitHub <noreply@github.com>2021-02-05 09:03:51 +0800
commit739fa266f80802f75838cc4053e615b27abcf361 (patch)
treeedcb787c5100142e00a2846fa7cc306e9b84814e
parentda24dfb59ea9c67d98f39daab4299b75c15978ea (diff)
downloadtracifyjs-739fa266f80802f75838cc4053e615b27abcf361.tar.gz
tracifyjs-739fa266f80802f75838cc4053e615b27abcf361.zip
fix corner case in `pure_getters` (#4615)
fixes #4614
-rw-r--r--lib/compress.js2
-rw-r--r--test/compress/spreads.js29
2 files changed, 30 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 5e18e52c..781b59f3 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -3441,7 +3441,7 @@ merge(Compressor.prototype, {
if (is_undeclared_ref(this) && this.is_declared(compressor)) return false;
if (this.is_immutable()) return false;
var def = this.definition();
- if (is_arguments(def) && all(def.scope.argnames, function(argname) {
+ if (is_arguments(def) && !def.scope.rest && all(def.scope.argnames, function(argname) {
return argname instanceof AST_SymbolFunarg;
})) return def.scope.uses_arguments > 2;
var fixed = this.fixed_value();
diff --git a/test/compress/spreads.js b/test/compress/spreads.js
index 7eac2482..a3a70035 100644
--- a/test/compress/spreads.js
+++ b/test/compress/spreads.js
@@ -918,3 +918,32 @@ issue_4560_3: {
expect_stdout: "PASS"
node_version: ">=6"
}
+
+issue_4614: {
+ options = {
+ pure_getters: "strict",
+ side_effects: true,
+ }
+ input: {
+ try {
+ (function(...[]) {
+ var arguments;
+ arguments[0];
+ })();
+ } catch (e) {
+ console.log("PASS");
+ }
+ }
+ expect: {
+ try {
+ (function(...[]) {
+ var arguments;
+ arguments[0];
+ })();
+ } catch (e) {
+ console.log("PASS");
+ }
+ }
+ expect_stdout: true
+ node_version: ">=6"
+}