Index: src/parsing/parser-base.h |
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h |
index a946cfa6bc825bbca6162cdaf4d97105f6c9aa4c..71b622c96662af3d3a2c07c2f9ca5dea4723032d 100644 |
--- a/src/parsing/parser-base.h |
+++ b/src/parsing/parser-base.h |
@@ -897,7 +897,7 @@ class ParserBase : public Traits { |
ExpressionT expr, |
bool parenthesized_formals, bool is_async, |
bool* ok) { |
- if (classifier->is_valid_binding_pattern()) { |
+ if (!is_async && classifier->is_valid_binding_pattern()) { |
// A simple arrow formal parameter: IDENTIFIER => BODY. |
if (!this->IsIdentifier(expr)) { |
Traits::ReportMessageAt(scanner()->location(), |
@@ -916,11 +916,17 @@ class ParserBase : public Traits { |
ReportClassifierError(error); |
*ok = false; |
} |
- if (is_async && !classifier->is_valid_async_arrow_formal_parameters()) { |
- const typename ExpressionClassifier::Error& error = |
- classifier->async_arrow_formal_parameters_error(); |
- ReportClassifierError(error); |
- *ok = false; |
+ if (is_async) { |
+ if (!classifier->is_valid_async_arrow_formal_parameters()) { |
+ const typename ExpressionClassifier::Error& error = |
+ classifier->async_arrow_formal_parameters_error(); |
+ ReportClassifierError(error); |
+ *ok = false; |
+ } |
+ if (!classifier->is_valid_binding_pattern()) { |
nickie
2016/07/11 13:19:50
Is it possible that we have both !is_valid_async_a
caitp
2016/07/11 13:24:42
Yeah, this is true --- the WebKit style is to just
nickie
2016/07/11 13:32:18
Yes, I think that adding return statements is a be
|
+ ReportClassifierError(classifier->binding_pattern_error()); |
+ *ok = false; |
+ } |
} |
} |
@@ -1024,7 +1030,12 @@ class ParserBase : public Traits { |
ExpressionT ParseAssignmentExpression(bool accept_IN, |
ExpressionClassifier* classifier, |
- bool* ok); |
+ bool marge_partterns, bool* ok); |
nickie
2016/07/11 13:19:50
Unless I'm missing the pun, "merge_patterns" :-)
caitp
2016/07/11 13:24:42
just a typo, will fix
|
+ ExpressionT ParseAssignmentExpression(bool accept_IN, |
+ ExpressionClassifier* classifier, |
+ bool* ok) { |
+ return ParseAssignmentExpression(accept_IN, classifier, false, ok); |
+ } |
ExpressionT ParseYieldExpression(bool accept_IN, |
ExpressionClassifier* classifier, bool* ok); |
ExpressionT ParseTailCallExpression(ExpressionClassifier* classifier, |
@@ -2172,7 +2183,7 @@ typename Traits::Type::ExpressionList ParserBase<Traits>::ParseArguments( |
int expr_pos = peek_position(); |
ExpressionT argument = this->ParseAssignmentExpression( |
- true, classifier, CHECK_OK_CUSTOM(NullExpressionList)); |
+ true, classifier, maybe_arrow, CHECK_OK_CUSTOM(NullExpressionList)); |
CheckNoTailCallExpressions(classifier, CHECK_OK_CUSTOM(NullExpressionList)); |
if (!maybe_arrow) { |
Traits::RewriteNonPattern(classifier, |
@@ -2239,7 +2250,7 @@ template <class Traits> |
typename ParserBase<Traits>::ExpressionT |
ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, |
ExpressionClassifier* classifier, |
- bool* ok) { |
+ bool merge_patterns, bool* ok) { |
// AssignmentExpression :: |
// ConditionalExpression |
// ArrowFunction |
@@ -2331,14 +2342,18 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, |
// "expression" was not itself an arrow function parameter list, but it might |
// form part of one. Propagate speculative formal parameter error locations. |
// Do not merge pending non-pattern expressions yet! |
- classifier->Accumulate( |
- &arrow_formals_classifier, |
+ int productions_to_propagate = |
ExpressionClassifier::StandardProductions | |
- ExpressionClassifier::FormalParametersProductions | |
- ExpressionClassifier::CoverInitializedNameProduction | |
- ExpressionClassifier::AsyncArrowFormalParametersProduction | |
- ExpressionClassifier::AsyncBindingPatternProduction, |
- false); |
+ ExpressionClassifier::FormalParametersProductions | |
+ ExpressionClassifier::CoverInitializedNameProduction | |
+ ExpressionClassifier::AsyncArrowFormalParametersProduction | |
+ ExpressionClassifier::AsyncBindingPatternProduction; |
+ if (merge_patterns) { |
Dan Ehrenberg
2016/07/11 23:22:47
I find this logic of when to merge_patterns to be
caitp
2016/07/11 23:32:24
That doesn't really work, because then we could fa
Dan Ehrenberg
2016/07/11 23:37:57
I don't understand the issue. The binding pattern
nickie
2016/07/12 13:11:53
I tried the following with Dan's patch and they se
caitp
2016/07/12 14:38:30
What are either of you even talking about? Using p
|
+ productions_to_propagate |= ExpressionClassifier::BindingPatternProduction; |
+ } |
+ |
+ classifier->Accumulate(&arrow_formals_classifier, productions_to_propagate, |
+ false); |
if (!Token::IsAssignmentOp(peek())) { |
// Parsed conditional expression only (no assignment). |
@@ -2805,7 +2820,16 @@ ParserBase<Traits>::ParseLeftHandSideExpression( |
CheckNoTailCallExpressions(classifier, CHECK_OK); |
int pos; |
Traits::RewriteNonPattern(classifier, CHECK_OK); |
- BindingPatternUnexpectedToken(classifier); |
+ |
+ const char* arg; |
+ MessageTemplate::Template message = MessageTemplate::kUnexpectedToken; |
+ Scanner::Location location = scanner()->peek_location(); |
+ GetUnexpectedTokenMessage(peek(), &message, &location, &arg); |
+ |
+ if (!is_async) { |
+ classifier->RecordBindingPatternError(location, message, arg); |
+ } |
+ |
if (scanner()->current_token() == Token::IDENTIFIER || |
scanner()->current_token() == Token::SUPER || |
scanner()->current_token() == Token::ASYNC) { |
@@ -2837,6 +2861,8 @@ ParserBase<Traits>::ParseLeftHandSideExpression( |
} |
// async () => ... |
return factory()->NewEmptyParentheses(pos); |
+ } else { |
+ classifier->ReplaceBindingPatternError(location, message, arg); |
Dan Ehrenberg
2016/07/11 23:22:47
I don't understand why this case is added when we'
caitp
2016/07/11 23:32:24
ArrowFormalParameters don't really matter for asyn
Dan Ehrenberg
2016/07/11 23:37:57
Could you write a test for it?
|
} |
ArrowFormalParametersUnexpectedToken(classifier); |