Commit e4fbac98 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Don't block PRIVATE_NAME in ParseObjectPropertyDefinition

This is already blocked when PRIVATE_NAME is parsed anyway, and we simply need
to make sure that we don't continue. So marking the prop_info->kind as kNotSet
will do what you want via the unexpected path rather than through the main hot
path.

Bug: v8:8808
Change-Id: I93beb80a89cf764cd79d6c3ec3a5fc763a98c4d6
Reviewed-on: https://chromium-review.googlesource.com/c/1472635Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59600}
parent 2da19bd4
......@@ -1978,11 +1978,17 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseProperty(
prop_info->ParsePropertyKindFromToken(peek());
}
prop_info->name = impl()->GetSymbol();
if (prop_info->position == PropertyPosition::kObjectLiteral ||
(!allow_harmony_private_methods() &&
(IsAccessor(prop_info->kind) ||
prop_info->kind == ParsePropertyKind::kMethod))) {
if (V8_UNLIKELY(prop_info->position ==
PropertyPosition::kObjectLiteral)) {
ReportUnexpectedToken(Token::PRIVATE_NAME);
prop_info->kind = ParsePropertyKind::kNotSet;
return impl()->FailureExpression();
}
if (V8_UNLIKELY(!allow_harmony_private_methods() &&
(IsAccessor(prop_info->kind) ||
prop_info->kind == ParsePropertyKind::kMethod))) {
ReportUnexpectedToken(Next());
prop_info->kind = ParsePropertyKind::kNotSet;
return impl()->FailureExpression();
}
break;
......@@ -2274,12 +2280,10 @@ ParserBase<Impl>::ParseObjectPropertyDefinition(ParsePropertyInfo* prop_info,
Token::Value name_token = peek();
Scanner::Location next_loc = scanner()->peek_location();
if (name_token == Token::PRIVATE_NAME) {
ReportUnexpectedToken(Next());
return impl()->NullLiteralProperty();
}
ExpressionT name_expression = ParseProperty(prop_info);
DCHECK_IMPLIES(name_token == Token::PRIVATE_NAME, has_error());
IdentifierT name = prop_info->name;
ParseFunctionFlags function_flags = prop_info->function_flags;
ParsePropertyKind kind = prop_info->kind;
......
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