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

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

Issue 2139063002: [parser] report errors for invalid binding patterns in async formal parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Cleanups Created 4 years, 5 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 | test/cctest/test-parsing.cc » ('j') | 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 a946cfa6bc825bbca6162cdaf4d97105f6c9aa4c..5c883f03cba2f6cc754681ef0be5329f1977b802 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -2827,16 +2827,30 @@ ParserBase<Traits>::ParseLeftHandSideExpression(
}
}
Scanner::Location spread_pos;
- typename Traits::Type::ExpressionList args =
- ParseArguments(&spread_pos, is_async, classifier, CHECK_OK);
-
- if (V8_UNLIKELY(is_async && peek() == Token::ARROW)) {
- if (args->length()) {
- // async ( Arguments ) => ...
- return Traits::ExpressionListToExpression(args);
+ typename Traits::Type::ExpressionList args;
+ if (V8_UNLIKELY(is_async)) {
+ ExpressionClassifier async_classifier(this);
+ args = ParseArguments(&spread_pos, true, &async_classifier, CHECK_OK);
+ if (peek() == Token::ARROW) {
+ ValidateBindingPattern(&async_classifier, CHECK_OK);
+ if (!async_classifier.is_valid_async_arrow_formal_parameters()) {
+ ReportClassifierError(
+ async_classifier.async_arrow_formal_parameters_error());
+ *ok = false;
+ return this->EmptyExpression();
+ }
+ if (args->length()) {
+ // async ( Arguments ) => ...
+ return Traits::ExpressionListToExpression(args);
+ }
+ // async () => ...
+ return factory()->NewEmptyParentheses(pos);
+ } else {
+ classifier->Accumulate(&async_classifier,
+ ExpressionClassifier::AllProductions);
}
- // async () => ...
- return factory()->NewEmptyParentheses(pos);
+ } else {
+ args = ParseArguments(&spread_pos, false, classifier, CHECK_OK);
}
ArrowFormalParametersUnexpectedToken(classifier);
« no previous file with comments | « no previous file | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698