Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Unified Diff: src/parsing/parser-base.h

Issue 1688833004: Cleanup destructuring-related error reporting in ParserBase (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index e75e87a65a427da96e9382f58b0a9a8c33fa8460..d54a4bb1bdb7b78e7a9fd5a521491d4fec76a7de 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -966,7 +966,6 @@ template <class Traits>
void ParserBase<Traits>::GetUnexpectedTokenMessage(
Token::Value token, MessageTemplate::Template* message, const char** arg,
MessageTemplate::Template default_) {
- // Four of the tokens are treated specially
switch (token) {
case Token::EOS:
*message = MessageTemplate::kUnexpectedEOS;
@@ -1090,10 +1089,8 @@ ParserBase<Traits>::ParseAndClassifyIdentifier(ExpressionClassifier* classifier,
scanner()->location(), MessageTemplate::kStrongUndefined);
if (is_strong(language_mode())) {
// TODO(dslomov): allow 'undefined' in nested patterns.
- classifier->RecordBindingPatternError(
- scanner()->location(), MessageTemplate::kStrongUndefined);
- classifier->RecordAssignmentPatternError(
- scanner()->location(), MessageTemplate::kStrongUndefined);
+ classifier->RecordPatternError(scanner()->location(),
+ MessageTemplate::kStrongUndefined);
}
}
@@ -1258,8 +1255,7 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier,
return this->ExpressionFromLiteral(Next(), beg_pos, scanner(), factory());
case Token::SMI:
case Token::NUMBER:
- classifier->RecordBindingPatternError(
- scanner()->peek_location(), MessageTemplate::kUnexpectedTokenNumber);
+ BindingPatternUnexpectedToken(classifier);
return this->ExpressionFromLiteral(Next(), beg_pos, scanner(), factory());
case Token::IDENTIFIER:
@@ -1275,8 +1271,7 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier,
}
case Token::STRING: {
- classifier->RecordBindingPatternError(
- scanner()->peek_location(), MessageTemplate::kUnexpectedTokenString);
+ BindingPatternUnexpectedToken(classifier);
Consume(Token::STRING);
return this->ExpressionFromString(beg_pos, scanner(), factory());
}
@@ -1322,9 +1317,6 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier,
classifier->RecordExpressionError(scanner()->location(),
MessageTemplate::kUnexpectedToken,
Token::String(Token::RPAREN));
- classifier->RecordBindingPatternError(scanner()->location(),
- MessageTemplate::kUnexpectedToken,
- Token::String(Token::RPAREN));
return factory()->NewEmptyParentheses(beg_pos);
} else if (Check(Token::ELLIPSIS)) {
// (...x)=>x. The continuation that looks for the => is in
@@ -1385,9 +1377,7 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier,
case Token::TEMPLATE_SPAN:
case Token::TEMPLATE_TAIL:
- classifier->RecordBindingPatternError(
- scanner()->peek_location(),
- MessageTemplate::kUnexpectedTemplateString);
+ BindingPatternUnexpectedToken(classifier);
return this->ParseTemplateLiteral(Traits::NoTemplateTag(), beg_pos,
classifier, ok);
@@ -1972,7 +1962,9 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, int flags,
ExpressionT expression = this->ParseConditionalExpression(
accept_IN, &arrow_formals_classifier, CHECK_OK);
if (peek() == Token::ARROW) {
- BindingPatternUnexpectedToken(classifier);
+ classifier->RecordPatternError(scanner()->peek_location(),
+ MessageTemplate::kUnexpectedToken,
+ Token::String(Token::ARROW));
ValidateArrowFormalParameters(&arrow_formals_classifier, expression,
parenthesized_formals, CHECK_OK);
Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos);
@@ -2000,11 +1992,6 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, int flags,
}
expression = this->ParseArrowFunctionLiteral(
accept_IN, parameters, arrow_formals_classifier, CHECK_OK);
- if (maybe_pattern_element) {
- classifier->RecordPatternError(
- Scanner::Location(lhs_beg_pos, scanner()->location().end_pos),
- MessageTemplate::kInvalidDestructuringTarget);
- }
if (fni_ != nullptr) fni_->Infer();
@@ -2063,9 +2050,9 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, int flags,
Token::Value op = Next(); // Get assignment operator.
if (op != Token::ASSIGN) {
- classifier->RecordBindingPatternError(scanner()->location(),
- MessageTemplate::kUnexpectedToken,
- Token::String(op));
+ classifier->RecordPatternError(scanner()->location(),
+ MessageTemplate::kUnexpectedToken,
+ Token::String(op));
}
int pos = position();
@@ -2087,12 +2074,6 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, int flags,
function_state_->AddProperty();
}
- if (op != Token::ASSIGN && maybe_pattern_element) {
- classifier->RecordAssignmentPatternError(
- Scanner::Location(lhs_beg_pos, scanner()->location().end_pos),
- MessageTemplate::kInvalidDestructuringTarget);
- }
-
this->CheckAssigningFunctionLiteralToProperty(expression, right);
if (fni_ != NULL) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698