Commit 27b52b2e authored by Joyee Cheung's avatar Joyee Cheung Committed by Commit Bot

[class] always ban #constructor

Previously variations of #constructor can be parsed when they are
static. This patch throws early errors for them always.

Bug: v8:8330
Change-Id: I51ab9b83f713c70d0896c0e8cab3282ef9a105f0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1770332Reviewed-by: 's avatarSathya Gunasekaran  <gsathya@chromium.org>
Commit-Queue: Joyee Cheung <joyee@igalia.com>
Cr-Commit-Position: refs/heads/master@{#63413}
parent b13d5ac6
...@@ -6062,15 +6062,14 @@ void ParserBase<Impl>::CheckClassMethodName(IdentifierT name, ...@@ -6062,15 +6062,14 @@ void ParserBase<Impl>::CheckClassMethodName(IdentifierT name,
AstValueFactory* avf = ast_value_factory(); AstValueFactory* avf = ast_value_factory();
if (is_static) { if (impl()->IdentifierEquals(name, avf->private_constructor_string())) {
ReportMessage(MessageTemplate::kConstructorIsPrivate);
return;
} else if (is_static) {
if (impl()->IdentifierEquals(name, avf->prototype_string())) { if (impl()->IdentifierEquals(name, avf->prototype_string())) {
ReportMessage(MessageTemplate::kStaticPrototype); ReportMessage(MessageTemplate::kStaticPrototype);
return; return;
} }
} else if (impl()->IdentifierEquals(name,
avf->private_constructor_string())) {
ReportMessage(MessageTemplate::kConstructorIsPrivate);
return;
} else if (impl()->IdentifierEquals(name, avf->constructor_string())) { } else if (impl()->IdentifierEquals(name, avf->constructor_string())) {
if (flags != ParseFunctionFlag::kIsNormal || IsAccessor(type)) { if (flags != ParseFunctionFlag::kIsNormal || IsAccessor(type)) {
MessageTemplate msg = (flags & ParseFunctionFlag::kIsGenerator) != 0 MessageTemplate msg = (flags & ParseFunctionFlag::kIsGenerator) != 0
......
...@@ -5657,6 +5657,14 @@ TEST(PrivateMethodsErrors) { ...@@ -5657,6 +5657,14 @@ TEST(PrivateMethodsErrors) {
"set #constructor(test) {}", "set #constructor(test) {}",
"#constructor() {}", "#constructor() {}",
"get #constructor() {}", "get #constructor() {}",
"static async *#constructor() {}",
"static *#constructor() {}",
"static async #constructor() {}",
"static set #constructor(test) {}",
"static #constructor() {}",
"static get #constructor() {}",
nullptr nullptr
}; };
// clang-format on // clang-format on
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment