From e13615549ef15954fa7317a504652b82cbb93c1c Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sat, 15 May 2021 19:12:58 +0100 Subject: [PATCH] fix corner case in `pure_getters` (#4940) fixes #4939 --- lib/compress.js | 3 ++- test/compress/pure_getters.js | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) 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" +}