Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,9 @@ impl<'a, 'b> PeepholeSubstituteAlternateSyntax {
};
let PropertyKey::StringLiteral(s) = key else { return };
let value = s.value.as_str();
if matches!(value, "__proto__" | "constructor" | "prototype") {
// Uncaught SyntaxError: Classes may not have a field named 'constructor'
// Uncaught SyntaxError: Class constructor may not be a private method
if matches!(value, "__proto__" | "prototype" | "constructor" | "#constructor") {
return;
}
if *computed {
Expand Down Expand Up @@ -1785,6 +1787,7 @@ mod test {
test_same("class C { ['prototype']() {} }");
test_same("class C { ['__proto__']() {} }");
test_same("class C { ['constructor']() {} }");
test_same("class C { ['#constructor']() {} }");
}

#[test]
Expand Down
Loading