Skip to content

Commit

Permalink
fix corner case in collapse_vars (#4915)
Browse files Browse the repository at this point in the history
fixes #4914
  • Loading branch information
alexlamsl committed May 7, 2021
1 parent 19d232b commit ac1f7d6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/compress.js
Expand Up @@ -1483,6 +1483,7 @@ merge(Compressor.prototype, {
function is_lhs_read_only(lhs, compressor) {
if (lhs instanceof AST_ObjectIdentity) return true;
if (lhs instanceof AST_PropAccess) {
if (lhs.property == "__proto__") return true;
lhs = lhs.expression;
if (lhs instanceof AST_SymbolRef) {
if (lhs.is_immutable()) return false;
Expand Down
20 changes: 20 additions & 0 deletions test/compress/collapse_vars.js
Expand Up @@ -9151,3 +9151,23 @@ issue_4910: {
}
expect_stdout: "bar foo"
}

issue_4914: {
options = {
collapse_vars: true,
pure_getters: "strict",
}
input: {
console.log(typeof function f() {
f.__proto__ = 42;
return f.__proto__;
}());
}
expect: {
console.log(typeof function f() {
f.__proto__ = 42;
return f.__proto__;
}());
}
expect_stdout: "function"
}

0 comments on commit ac1f7d6

Please sign in to comment.