aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-05-15 19:12:58 +0100
committerGitHub <noreply@github.com>2021-05-16 02:12:58 +0800
commite13615549ef15954fa7317a504652b82cbb93c1c (patch)
tree8cc12b4e8685ffe594a2fbb236c6dc972887ef63
parenta7698f88455b3bfc40b6543c812e6a795f00cd99 (diff)
downloadtracifyjs-e13615549ef15954fa7317a504652b82cbb93c1c.tar.gz
tracifyjs-e13615549ef15954fa7317a504652b82cbb93c1c.zip
fix corner case in `pure_getters` (#4940)
fixes #4939
-rw-r--r--lib/compress.js3
-rw-r--r--test/compress/pure_getters.js26
2 files changed, 28 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 1c49ee79..6bc5d3b4 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -3776,7 +3776,8 @@ merge(Compressor.prototype, {
def(AST_Null, return_true);
def(AST_Object, function(compressor, force) {
return is_strict(compressor, force) && !all(this.properties, function(prop) {
- return prop instanceof AST_ObjectKeyVal;
+ if (!(prop instanceof AST_ObjectKeyVal)) return false;
+ return !(prop.key == "__proto__" && prop.value._dot_throw(compressor, force));
});
});
def(AST_ObjectIdentity, function(compressor, force) {
diff --git a/test/compress/pure_getters.js b/test/compress/pure_getters.js
index 2a20c339..935b3e31 100644
--- a/test/compress/pure_getters.js
+++ b/test/compress/pure_getters.js
@@ -1638,3 +1638,29 @@ nested_property_assignments_3: {
}
expect_stdout: "PASS"
}
+
+issue_4939: {
+ options = {
+ pure_getters: "strict",
+ side_effects: true,
+ }
+ input: {
+ ({
+ __proto__: {
+ get p() {
+ console.log("PASS");
+ },
+ },
+ }).p;
+ }
+ expect: {
+ ({
+ __proto__: {
+ get p() {
+ console.log("PASS");
+ },
+ },
+ }).p;
+ }
+ expect_stdout: "PASS"
+}