Index: src/parsing/expression-classifier.h |
diff --git a/src/parsing/expression-classifier.h b/src/parsing/expression-classifier.h |
index dfb582d326504bee5aa4d246432d1749f104a2d2..3f70ed82d060965cce15739cb5f3cada9f204354 100644 |
--- a/src/parsing/expression-classifier.h |
+++ b/src/parsing/expression-classifier.h |
@@ -40,18 +40,22 @@ class ExpressionClassifier { |
LetPatternProduction = 1 << 7, |
CoverInitializedNameProduction = 1 << 8, |
TailCallExpressionProduction = 1 << 9, |
+ AsyncArrowFormalParametersProduction = 1 << 10, |
+ AsyncBindingPatternProduction = 1 << 11, |
ExpressionProductions = |
(ExpressionProduction | FormalParameterInitializerProduction | |
TailCallExpressionProduction), |
- PatternProductions = (BindingPatternProduction | |
- AssignmentPatternProduction | LetPatternProduction), |
+ PatternProductions = |
+ (BindingPatternProduction | AssignmentPatternProduction | |
+ LetPatternProduction | AsyncBindingPatternProduction), |
FormalParametersProductions = (DistinctFormalParametersProduction | |
StrictModeFormalParametersProduction), |
StandardProductions = ExpressionProductions | PatternProductions, |
AllProductions = |
(StandardProductions | FormalParametersProductions | |
- ArrowFormalParametersProduction | CoverInitializedNameProduction) |
+ ArrowFormalParametersProduction | CoverInitializedNameProduction | |
+ AsyncArrowFormalParametersProduction | AsyncBindingPatternProduction) |
}; |
enum FunctionProperties { NonSimpleParameter = 1 << 0 }; |
@@ -112,6 +116,14 @@ class ExpressionClassifier { |
bool is_valid_let_pattern() const { return is_valid(LetPatternProduction); } |
+ bool is_valid_async_arrow_formal_parameters() const { |
+ return is_valid(AsyncArrowFormalParametersProduction); |
+ } |
+ |
+ bool is_valid_async_binding_pattern() const { |
+ return is_valid(AsyncBindingPatternProduction); |
+ } |
+ |
const Error& expression_error() const { return expression_error_; } |
const Error& formal_parameter_initializer_error() const { |
@@ -151,6 +163,13 @@ class ExpressionClassifier { |
const Error& tail_call_expression_error() const { |
return tail_call_expression_error_; |
} |
+ const Error& async_arrow_formal_parameters_error() const { |
+ return async_arrow_formal_parameters_error_; |
+ } |
+ |
+ const Error& async_binding_pattern_error() const { |
+ return async_binding_pattern_error_; |
+ } |
bool is_simple_parameter_list() const { |
return !(function_properties_ & NonSimpleParameter); |
@@ -228,6 +247,26 @@ class ExpressionClassifier { |
arrow_formal_parameters_error_.arg = arg; |
} |
+ void RecordAsyncArrowFormalParametersError(const Scanner::Location& loc, |
+ MessageTemplate::Template message, |
+ const char* arg = nullptr) { |
+ if (!is_valid_async_arrow_formal_parameters()) return; |
+ invalid_productions_ |= AsyncArrowFormalParametersProduction; |
+ async_arrow_formal_parameters_error_.location = loc; |
+ async_arrow_formal_parameters_error_.message = message; |
+ async_arrow_formal_parameters_error_.arg = arg; |
+ } |
+ |
+ void RecordAsyncBindingPatternError(const Scanner::Location& loc, |
+ MessageTemplate::Template message, |
+ const char* arg = nullptr) { |
+ if (!is_valid_async_binding_pattern()) return; |
+ invalid_productions_ |= AsyncBindingPatternProduction; |
+ async_binding_pattern_error_.location = loc; |
+ async_binding_pattern_error_.message = message; |
+ async_binding_pattern_error_.arg = arg; |
+ } |
+ |
void RecordDuplicateFormalParameterError(const Scanner::Location& loc) { |
if (!is_valid_formal_parameter_list_without_duplicates()) return; |
invalid_productions_ |= DistinctFormalParametersProduction; |
@@ -326,6 +365,11 @@ class ExpressionClassifier { |
cover_initialized_name_error_ = inner->cover_initialized_name_error_; |
if (errors & TailCallExpressionProduction) |
tail_call_expression_error_ = inner->tail_call_expression_error_; |
+ if (errors & AsyncArrowFormalParametersProduction) |
+ async_arrow_formal_parameters_error_ = |
+ inner->async_arrow_formal_parameters_error_; |
+ if (errors & AsyncBindingPatternProduction) |
+ async_binding_pattern_error_ = inner->async_binding_pattern_error_; |
} |
// As an exception to the above, the result continues to be a valid arrow |
@@ -373,6 +417,8 @@ class ExpressionClassifier { |
Error let_pattern_error_; |
Error cover_initialized_name_error_; |
Error tail_call_expression_error_; |
+ Error async_arrow_formal_parameters_error_; |
+ Error async_binding_pattern_error_; |
DuplicateFinder* duplicate_finder_; |
}; |