Skip to content

Commit

Permalink
fix corner case in pure_getters (#4940)
Browse files Browse the repository at this point in the history
fixes #4939
  • Loading branch information
alexlamsl committed May 15, 2021
1 parent a7698f8 commit e136155
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
26 changes: 26 additions & 0 deletions test/compress/pure_getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit e136155

Please sign in to comment.