aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-12-23 20:09:09 +0000
committerGitHub <noreply@github.com>2020-12-24 04:09:09 +0800
commit56fce2131c86ed58ac00bb27b308054b1c2a669f (patch)
tree0cada8388d8f29d38ffa80cceaaf703fede5464a
parent7e575e9d7f40876373f073213126b729553c4d89 (diff)
downloadtracifyjs-56fce2131c86ed58ac00bb27b308054b1c2a669f.tar.gz
tracifyjs-56fce2131c86ed58ac00bb27b308054b1c2a669f.zip
fix corner case in `pure_getters` (#4441)
fixes #4440
-rw-r--r--lib/compress.js3
-rw-r--r--test/compress/pure_getters.js29
2 files changed, 31 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index c397a605..13b7306b 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -3237,7 +3237,8 @@ merge(Compressor.prototype, {
if (!is_strict(compressor)) return false;
if (is_undeclared_ref(this) && this.is_declared(compressor)) return false;
if (this.is_immutable()) return false;
- if (is_arguments(this.definition())) return false;
+ var def = this.definition();
+ if (is_arguments(def)) return def.scope.uses_arguments > 2;
var fixed = this.fixed_value();
if (!fixed) return true;
this._dot_throw = return_true;
diff --git a/test/compress/pure_getters.js b/test/compress/pure_getters.js
index 25efd7fd..1cb2ff13 100644
--- a/test/compress/pure_getters.js
+++ b/test/compress/pure_getters.js
@@ -1208,3 +1208,32 @@ issue_3427: {
expect: {}
expect_stdout: true
}
+
+issue_4440: {
+ options = {
+ pure_getters: "strict",
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ try {
+ (function() {
+ arguments = null;
+ console.log(arguments.p = "FAIL");
+ })();
+ } catch (e) {
+ console.log("PASS");
+ }
+ }
+ expect: {
+ try {
+ (function() {
+ arguments = null;
+ console.log(arguments.p = "FAIL");
+ })();
+ } catch (e) {
+ console.log("PASS");
+ }
+ }
+ expect_stdout: "PASS"
+}