Index: src/preparser.h |
diff --git a/src/preparser.h b/src/preparser.h |
index 91e37912d163926131607322f3f1064b8c13b017..fd7a89db0e11884c09794aa966ffb4820f810ed0 100644 |
--- a/src/preparser.h |
+++ b/src/preparser.h |
@@ -1639,7 +1639,9 @@ class PreParserTraits { |
} |
void DeclareFormalParameter(Scope* scope, PreParserIdentifier parameter, |
bool is_simple, |
- ExpressionClassifier* classifier) {} |
+ ExpressionClassifier* classifier) { |
+ if (!is_simple) scope->SetHasNonSimpleParameters(); |
+ } |
void CheckConflictingVarDeclarations(Scope* scope, bool* ok) {} |
@@ -1737,8 +1739,8 @@ class PreParser : public ParserBase<PreParserTraits> { |
// At return, unless an error occurred, the scanner is positioned before the |
// the final '}'. |
PreParseResult PreParseLazyFunction( |
- LanguageMode language_mode, FunctionKind kind, ParserRecorder* log, |
- Scanner::BookmarkScope* bookmark = nullptr); |
+ LanguageMode language_mode, FunctionKind kind, bool has_simple_parameters, |
+ ParserRecorder* log, Scanner::BookmarkScope* bookmark = nullptr); |
private: |
friend class PreParserTraits; |
@@ -2304,6 +2306,10 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier, |
parenthesized_function_ = (peek() == Token::FUNCTION); |
result = this->ParseExpression(true, classifier, CHECK_OK); |
Expect(Token::RPAREN, CHECK_OK); |
+ if (peek() == Token::ARROW) { |
+ int x = 5; |
+ USE(x); |
+ } |
} |
break; |
@@ -2379,6 +2385,7 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseExpression( |
ExpressionClassifier binding_classifier; |
ExpressionT result = |
this->ParseAssignmentExpression(accept_IN, &binding_classifier, CHECK_OK); |
+ bool is_simple_parameter_list = this->IsIdentifier(result); |
classifier->Accumulate(binding_classifier, |
ExpressionClassifier::AllProductions); |
bool seen_rest = false; |
@@ -2404,10 +2411,16 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseExpression( |
ExpressionT right = this->ParseAssignmentExpression( |
accept_IN, &binding_classifier, CHECK_OK); |
if (is_rest) right = factory()->NewSpread(right, pos); |
+ if (is_simple_parameter_list) { |
+ is_simple_parameter_list = this->IsIdentifier(result); |
+ } |
classifier->Accumulate(binding_classifier, |
ExpressionClassifier::AllProductions); |
result = factory()->NewBinaryOperation(Token::COMMA, result, right, pos); |
} |
+ if (!is_simple_parameter_list) { |
+ classifier->RecordNonSimpleParameter(); |
+ } |
return result; |
} |
@@ -2843,7 +2856,10 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, |
Scanner::Location loc(lhs_location.beg_pos, scanner()->location().end_pos); |
Scope* scope = |
this->NewScope(scope_, ARROW_SCOPE, FunctionKind::kArrowFunction); |
+ bool is_simple = arrow_formals_classifier.is_simple_parameter_list(); |
+ if (!is_simple) scope->SetHasNonSimpleParameters(); |
FormalParametersT parameters(scope); |
+ parameters.is_simple = is_simple; |
checkpoint.Restore(¶meters.materialized_literals_count); |
scope->set_start_position(lhs_location.beg_pos); |
@@ -3765,6 +3781,14 @@ ParserBase<Traits>::ParseArrowFunctionLiteral( |
Expect(Token::ARROW, CHECK_OK); |
+ // Arrow function formal parameters are parsed as StrictFormalParameterList, |
+ // which is not the same as "parameters of a strict function"; it only means |
+ // that duplicates are not allowed. Of course, the arrow function may |
+ // itself be strict as well. |
+ const bool allow_duplicate_parameters = false; |
+ this->ValidateFormalParameters(&formals_classifier, language_mode(), |
+ allow_duplicate_parameters, CHECK_OK); |
+ |
if (peek() == Token::LBRACE) { |
// Multiple statement body |
Consume(Token::LBRACE); |
@@ -3800,14 +3824,6 @@ ParserBase<Traits>::ParseArrowFunctionLiteral( |
formal_parameters.scope->set_end_position(scanner()->location().end_pos); |
- // Arrow function formal parameters are parsed as StrictFormalParameterList, |
- // which is not the same as "parameters of a strict function"; it only means |
- // that duplicates are not allowed. Of course, the arrow function may |
- // itself be strict as well. |
- const bool allow_duplicate_parameters = false; |
- this->ValidateFormalParameters(&formals_classifier, language_mode(), |
- allow_duplicate_parameters, CHECK_OK); |
- |
// Validate strict mode. |
if (is_strict(language_mode())) { |
CheckStrictOctalLiteral(formal_parameters.scope->start_position(), |