[optional-chaining] Disallow optional chaining with private names.
Bug: chromium:1014458 Change-Id: I9e5e83da4452e9953218335353047f41c18f68fe Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1864333 Commit-Queue: Joshua Litt <joshualitt@chromium.org> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/master@{#64428}
This commit is contained in:
parent
dd29ce3ee3
commit
d6f911368b
@ -3277,7 +3277,13 @@ ParserBase<Impl>::ParseLeftHandSideContinuation(ExpressionT result) {
|
||||
if (is_optional) {
|
||||
DCHECK_EQ(scanner()->current_token(), Token::QUESTION_PERIOD);
|
||||
int pos = position();
|
||||
ExpressionT key = ParsePropertyOrPrivatePropertyName();
|
||||
Token::Value next = Next();
|
||||
if (V8_UNLIKELY(!Token::IsPropertyName(next))) {
|
||||
ReportUnexpectedToken(next);
|
||||
return impl()->FailureExpression();
|
||||
}
|
||||
IdentifierT name = impl()->GetSymbol();
|
||||
ExpressionT key = factory()->NewStringLiteral(name, position());
|
||||
result = factory()->NewProperty(result, key, pos, is_optional);
|
||||
break;
|
||||
}
|
||||
|
@ -101,6 +101,7 @@ shouldThrowSyntaxError('function foo() { new?.target; }');
|
||||
|
||||
shouldThrowSyntaxError('function tag() {} tag?.``;');
|
||||
shouldThrowSyntaxError('const o = { tag() {} }; o?.tag``;');
|
||||
shouldThrowSyntaxError('class A { #foo = "hi"; constructor() { this?.#foo; } }')
|
||||
|
||||
const o2 = {
|
||||
count: 0,
|
||||
|
Loading…
Reference in New Issue
Block a user