Commit 40b3626e authored by adamk's avatar adamk Committed by Commit bot

Disallow yield in computed property names of class expressions in params

R=littledan@chromium.org
BUG=v8:4974
LOG=n

Review-Url: https://codereview.chromium.org/1949223002
Cr-Commit-Position: refs/heads/master@{#36047}
parent 75f2d65f
...@@ -4678,12 +4678,16 @@ ClassLiteral* Parser::ParseClassLiteral(ExpressionClassifier* classifier, ...@@ -4678,12 +4678,16 @@ ClassLiteral* Parser::ParseClassLiteral(ExpressionClassifier* classifier,
const bool is_static = false; const bool is_static = false;
bool is_computed_name = false; // Classes do not care about computed bool is_computed_name = false; // Classes do not care about computed
// property names here. // property names here.
ExpressionClassifier classifier(this); ExpressionClassifier property_classifier(this);
const AstRawString* property_name = nullptr; const AstRawString* property_name = nullptr;
ObjectLiteral::Property* property = ParsePropertyDefinition( ObjectLiteral::Property* property = ParsePropertyDefinition(
&checker, in_class, has_extends, is_static, &is_computed_name, &checker, in_class, has_extends, is_static, &is_computed_name,
&has_seen_constructor, &classifier, &property_name, CHECK_OK); &has_seen_constructor, &property_classifier, &property_name, CHECK_OK);
RewriteNonPattern(&classifier, CHECK_OK); RewriteNonPattern(&property_classifier, CHECK_OK);
if (classifier != nullptr) {
classifier->Accumulate(&property_classifier,
ExpressionClassifier::ExpressionProductions);
}
if (has_seen_constructor && constructor == NULL) { if (has_seen_constructor && constructor == NULL) {
constructor = GetPropertyValue(property)->AsFunctionLiteral(); constructor = GetPropertyValue(property)->AsFunctionLiteral();
......
...@@ -1176,11 +1176,15 @@ PreParserExpression PreParser::ParseClassLiteral( ...@@ -1176,11 +1176,15 @@ PreParserExpression PreParser::ParseClassLiteral(
bool is_computed_name = false; // Classes do not care about computed bool is_computed_name = false; // Classes do not care about computed
// property names here. // property names here.
Identifier name; Identifier name;
ExpressionClassifier classifier(this); ExpressionClassifier property_classifier(this);
ParsePropertyDefinition(&checker, in_class, has_extends, is_static, ParsePropertyDefinition(&checker, in_class, has_extends, is_static,
&is_computed_name, &has_seen_constructor, &is_computed_name, &has_seen_constructor,
&classifier, &name, CHECK_OK); &property_classifier, &name, CHECK_OK);
ValidateExpression(&classifier, CHECK_OK); ValidateExpression(&property_classifier, CHECK_OK);
if (classifier != nullptr) {
classifier->Accumulate(&property_classifier,
ExpressionClassifier::ExpressionProductions);
}
} }
Expect(Token::RBRACE, CHECK_OK); Expect(Token::RBRACE, CHECK_OK);
......
...@@ -6781,6 +6781,10 @@ TEST(DefaultParametersYieldInInitializers) { ...@@ -6781,6 +6781,10 @@ TEST(DefaultParametersYieldInInitializers) {
"[x] = [class extends (a ? null : yield) { }]", "[x] = [class extends (a ? null : yield) { }]",
"[x = class extends (a ? null : yield) { }]", "[x = class extends (a ? null : yield) { }]",
"[x = class extends (a ? null : yield) { }] = [null]", "[x = class extends (a ? null : yield) { }] = [null]",
"x = class { [yield]() { } }",
"x = class { static [yield]() { } }",
"x = class { [(yield, 1)]() { } }",
"x = class { [y = (yield, 1)]() { } }",
NULL NULL
}; };
// 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