Chromium Code Reviews| Index: src/parsing/parser-base.h |
| diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h |
| index 7202c981e566165d4cf8495e86aad758ae2ae5ae..b475f1f15b539f43c554bdb1e6022ea6548a3731 100644 |
| --- a/src/parsing/parser-base.h |
| +++ b/src/parsing/parser-base.h |
| @@ -784,15 +784,6 @@ class ParserBase : public Traits { |
| classifier->RecordArrowFormalParametersError(location, message, arg); |
| } |
| - void FormalParameterInitializerUnexpectedToken( |
| - ExpressionClassifier* classifier) { |
| - MessageTemplate::Template message = MessageTemplate::kUnexpectedToken; |
| - const char* arg; |
| - Scanner::Location location = scanner()->peek_location(); |
| - GetUnexpectedTokenMessage(peek(), &message, &location, &arg); |
| - classifier->RecordFormalParameterInitializerError(location, message, arg); |
| - } |
| - |
| // Recursive descent functions: |
| // Parses an identifier that is valid for the current scope, in particular it |
| @@ -1415,7 +1406,7 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier, |
| CHECK_OK); |
| class_name_location = scanner()->location(); |
| } |
| - return this->ParseClassLiteral(name, class_name_location, |
| + return this->ParseClassLiteral(classifier, name, class_name_location, |
| is_strict_reserved_name, |
| class_token_position, ok); |
| } |
| @@ -1990,6 +1981,13 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, |
| Token::String(Token::ARROW)); |
| ValidateArrowFormalParameters(&arrow_formals_classifier, expression, |
| parenthesized_formals, CHECK_OK); |
| + // This reads strangely, but is correct: it checks whether any |
| + // sub-expression of the parameter list failed to be a valid formal |
| + // parameter initializer. Since YieldExpressions are banned anywhere |
| + // in an arrow parameter list, this is correct. |
| + // TODO(adamk): Rename "FormalParameterInitializerError" to refer to |
| + // "YieldExpression", which is its only use. |
|
Dan Ehrenberg
2016/05/02 23:11:43
You probably want to remove this TODO
adamk
2016/05/02 23:14:18
I actually also want to rename the methods on Expr
|
| + ValidateFormalParameterInitializer(&arrow_formals_classifier, ok); |
| Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos); |
| Scope* scope = |
| this->NewScope(scope_, FUNCTION_SCOPE, FunctionKind::kArrowFunction); |
| @@ -2126,7 +2124,8 @@ ParserBase<Traits>::ParseYieldExpression(bool accept_IN, |
| int pos = peek_position(); |
| classifier->RecordPatternError(scanner()->peek_location(), |
| MessageTemplate::kInvalidDestructuringTarget); |
| - FormalParameterInitializerUnexpectedToken(classifier); |
| + classifier->RecordFormalParameterInitializerError( |
| + scanner()->peek_location(), MessageTemplate::kYieldInParameter); |
| Expect(Token::YIELD, CHECK_OK); |
| ExpressionT generator_object = |
| factory()->NewVariableProxy(function_state_->generator_object_variable()); |