Commit 72ce4de2 authored by Sathya Gunasekaran's avatar Sathya Gunasekaran

[parser] Refactor ParseSuperExpression

Throw error when accessing private field on super.

Bug: v8:8872
Change-Id: Iad383890fafbdccdd6b6b75a8f9eb32c9d6f5044
Reviewed-on: https://chromium-review.googlesource.com/c/1478219Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59746}
parent bab66151
......@@ -478,6 +478,7 @@ namespace internal {
T(TypedArrayTooShort, \
"Derived TypedArray constructor created an array which was too small") \
T(UnexpectedEOS, "Unexpected end of input") \
T(UnexpectedPrivateField, "Unexpected private field") \
T(UnexpectedReserved, "Unexpected reserved word") \
T(UnexpectedStrictReserved, "Unexpected strict mode reserved word") \
T(UnexpectedSuper, "'super' keyword unexpected here") \
......
......@@ -3318,6 +3318,13 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseSuperExpression(
if (IsConciseMethod(kind) || IsAccessorFunction(kind) ||
IsClassConstructor(kind)) {
if (Token::IsProperty(peek())) {
if (peek() == Token::PERIOD && PeekAhead() == Token::PRIVATE_NAME) {
Consume(Token::PERIOD);
Consume(Token::PRIVATE_NAME);
impl()->ReportMessage(MessageTemplate::kUnexpectedPrivateField);
return impl()->FailureExpression();
}
scope->RecordSuperPropertyUsage();
UseThis();
return impl()->NewSuperPropertyReference(pos);
......
......@@ -588,10 +588,6 @@
'language/comments/hashbang/preceding-whitespace': [FAIL],
'language/comments/hashbang/use-strict': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=8872
'language/statements/class/elements/syntax/early-errors/grammar-private-field-super-access': [SKIP],
'language/expressions/class/elements/syntax/early-errors/grammar-private-field-super-access': [SKIP],
######################## NEEDS INVESTIGATION ###########################
# https://bugs.chromium.org/p/v8/issues/detail?id=7833
......
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