fix corner case in collapse_vars (#4915)

fixes #4914
This commit is contained in:
Alex Lam S.L
2021-05-07 18:14:59 +01:00
committed by GitHub
parent 19d232badb
commit ac1f7d689b
2 changed files with 21 additions and 0 deletions

View File

@@ -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;

View File

@@ -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"
}