diff options
Diffstat (limited to 'deps/v8/src/parsing/parser-base.h')
-rw-r--r-- | deps/v8/src/parsing/parser-base.h | 266 |
1 files changed, 199 insertions, 67 deletions
diff --git a/deps/v8/src/parsing/parser-base.h b/deps/v8/src/parsing/parser-base.h index 2dfb0d2461..f43496b429 100644 --- a/deps/v8/src/parsing/parser-base.h +++ b/deps/v8/src/parsing/parser-base.h @@ -6,6 +6,7 @@ #define V8_PARSING_PARSER_BASE_H_ #include <stdint.h> +#include <utility> #include <vector> #include "src/ast/ast-source-ranges.h" @@ -284,11 +285,21 @@ class ParserBase { #undef ALLOW_ACCESSORS V8_INLINE bool has_error() const { return scanner()->has_parser_error(); } - bool allow_harmony_numeric_separator() const { - return scanner()->allow_harmony_numeric_separator(); + + bool allow_harmony_optional_chaining() const { + return scanner()->allow_harmony_optional_chaining(); + } + + void set_allow_harmony_optional_chaining(bool allow) { + scanner()->set_allow_harmony_optional_chaining(allow); + } + + bool allow_harmony_nullish() const { + return scanner()->allow_harmony_nullish(); } - void set_allow_harmony_numeric_separator(bool allow) { - scanner()->set_allow_harmony_numeric_separator(allow); + + void set_allow_harmony_nullish(bool allow) { + scanner()->set_allow_harmony_nullish(allow); } uintptr_t stack_limit() const { return stack_limit_; } @@ -624,9 +635,17 @@ class ParserBase { } } - RequiresBrandCheckFlag RequiresBrandCheck(ClassLiteralProperty::Kind kind) { - return kind == ClassLiteralProperty::Kind::FIELD ? kNoBrandCheck - : kRequiresBrandCheck; + VariableMode GetVariableMode(ClassLiteralProperty::Kind kind) { + switch (kind) { + case ClassLiteralProperty::Kind::FIELD: + return VariableMode::kConst; + case ClassLiteralProperty::Kind::METHOD: + return VariableMode::kPrivateMethod; + case ClassLiteralProperty::Kind::GETTER: + return VariableMode::kPrivateGetterOnly; + case ClassLiteralProperty::Kind::SETTER: + return VariableMode::kPrivateSetterOnly; + } } const AstRawString* ClassFieldVariableName(AstValueFactory* ast_value_factory, @@ -1019,7 +1038,8 @@ class ParserBase { ExpressionT ParseAssignmentExpressionCoverGrammar(); ExpressionT ParseArrowParametersWithRest(ExpressionListT* list, - AccumulationScope* scope); + AccumulationScope* scope, + int seen_variables); ExpressionT ParseArrayLiteral(); @@ -1047,6 +1067,8 @@ class ParserBase { ExpressionT ParseYieldExpression(); V8_INLINE ExpressionT ParseConditionalExpression(); ExpressionT ParseConditionalContinuation(ExpressionT expression, int pos); + ExpressionT ParseLogicalExpression(); + ExpressionT ParseCoalesceExpression(ExpressionT expression); ExpressionT ParseBinaryContinuation(ExpressionT x, int prec, int prec1); V8_INLINE ExpressionT ParseBinaryExpression(int prec); ExpressionT ParseUnaryOrPrefixExpression(); @@ -1106,7 +1128,7 @@ class ParserBase { void ParseFunctionBody(StatementListT* body, IdentifierT function_name, int pos, const FormalParametersT& parameters, FunctionKind kind, - FunctionLiteral::FunctionType function_type, + FunctionSyntaxKind function_syntax_kind, FunctionBodyType body_type); // Check if the scope has conflicting var/let declarations from different @@ -1271,18 +1293,7 @@ class ParserBase { Scope* scope) { if (impl()->IsIdentifier(expression) && impl()->IsEval(impl()->AsIdentifier(expression))) { - scope->RecordInnerScopeEvalCall(); function_state_->RecordFunctionOrEvalCall(); - if (is_sloppy(scope->language_mode())) { - // For sloppy scopes we also have to record the call at function level, - // in case it includes declarations that will be hoisted. - scope->GetDeclarationScope()->RecordEvalCall(); - } - - // This call is only necessary to track evals that may be - // inside arrow function parameter lists. In that case, - // Scope::Snapshot::Reparent will move this bit down into - // the arrow function's scope. scope->RecordEvalCall(); return Call::IS_POSSIBLY_EVAL; @@ -1320,6 +1331,11 @@ class ParserBase { return expression_scope_; } + bool MaybeParsingArrowhead() const { + return expression_scope_ != nullptr && + expression_scope_->has_possible_arrow_parameter_in_scope_chain(); + } + class AcceptINScope final { public: AcceptINScope(ParserBase* parser, bool accept_IN) @@ -1365,7 +1381,9 @@ class ParserBase { }; std::vector<void*>* pointer_buffer() { return &pointer_buffer_; } - std::vector<void*>* variable_buffer() { return &variable_buffer_; } + std::vector<std::pair<VariableProxy*, int>>* variable_buffer() { + return &variable_buffer_; + } // Parser base's protected field members. @@ -1390,7 +1408,7 @@ class ParserBase { ExpressionScope* expression_scope_; std::vector<void*> pointer_buffer_; - std::vector<void*> variable_buffer_; + std::vector<std::pair<VariableProxy*, int>> variable_buffer_; Scanner* scanner_; @@ -1688,6 +1706,7 @@ ParserBase<Impl>::ParsePrimaryExpression() { ClassifyParameter(name, beg_pos, end_position()); ExpressionT result = impl()->ExpressionFromIdentifier(name, beg_pos, InferName::kNo); + parsing_scope.SetInitializers(0, peek_position()); next_arrow_function_info_.scope = parsing_scope.ValidateAndCreateScope(); return result; } @@ -1825,9 +1844,11 @@ ParserBase<Impl>::ParseExpressionCoverGrammar() { ExpressionListT list(pointer_buffer()); ExpressionT expression; AccumulationScope accumulation_scope(expression_scope()); + int variable_index = 0; while (true) { if (V8_UNLIKELY(peek() == Token::ELLIPSIS)) { - return ParseArrowParametersWithRest(&list, &accumulation_scope); + return ParseArrowParametersWithRest(&list, &accumulation_scope, + variable_index); } int expr_pos = peek_position(); @@ -1836,6 +1857,9 @@ ParserBase<Impl>::ParseExpressionCoverGrammar() { ClassifyArrowParameter(&accumulation_scope, expr_pos, expression); list.Add(expression); + variable_index = + expression_scope()->SetInitializers(variable_index, peek_position()); + if (!Check(Token::COMMA)) break; if (peek() == Token::RPAREN && PeekAhead() == Token::ARROW) { @@ -1863,7 +1887,7 @@ template <typename Impl> typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseArrowParametersWithRest( typename ParserBase<Impl>::ExpressionListT* list, - AccumulationScope* accumulation_scope) { + AccumulationScope* accumulation_scope, int seen_variables) { Consume(Token::ELLIPSIS); Scanner::Location ellipsis = scanner()->location(); @@ -1885,6 +1909,8 @@ ParserBase<Impl>::ParseArrowParametersWithRest( return impl()->FailureExpression(); } + expression_scope()->SetInitializers(seen_variables, peek_position()); + // 'x, y, ...z' in CoverParenthesizedExpressionAndArrowParameterList only // as the formal parameters of'(x, y, ...z) => foo', and is not itself a // valid expression. @@ -2204,7 +2230,7 @@ ParserBase<Impl>::ParseClassPropertyDefinition(ClassInfo* class_info, ExpressionT value = impl()->ParseFunctionLiteral( prop_info->name, scanner()->location(), kSkipFunctionNameCheck, kind, - name_token_position, FunctionLiteral::kAccessorOrMethod, + name_token_position, FunctionSyntaxKind::kAccessorOrMethod, language_mode(), nullptr); ClassLiteralPropertyT result = factory()->NewClassLiteralProperty( @@ -2236,7 +2262,7 @@ ParserBase<Impl>::ParseClassPropertyDefinition(ClassInfo* class_info, FunctionLiteralT value = impl()->ParseFunctionLiteral( prop_info->name, scanner()->location(), kSkipFunctionNameCheck, kind, - name_token_position, FunctionLiteral::kAccessorOrMethod, + name_token_position, FunctionSyntaxKind::kAccessorOrMethod, language_mode(), nullptr); ClassLiteralProperty::Kind property_kind = @@ -2417,8 +2443,8 @@ ParserBase<Impl>::ParseObjectPropertyDefinition(ParsePropertyInfo* prop_info, ExpressionT value = impl()->ParseFunctionLiteral( name, scanner()->location(), kSkipFunctionNameCheck, kind, - next_loc.beg_pos, FunctionLiteral::kAccessorOrMethod, language_mode(), - nullptr); + next_loc.beg_pos, FunctionSyntaxKind::kAccessorOrMethod, + language_mode(), nullptr); ObjectLiteralPropertyT result = factory()->NewObjectLiteralProperty( name_expression, value, ObjectLiteralProperty::COMPUTED, @@ -2449,8 +2475,8 @@ ParserBase<Impl>::ParseObjectPropertyDefinition(ParsePropertyInfo* prop_info, FunctionLiteralT value = impl()->ParseFunctionLiteral( name, scanner()->location(), kSkipFunctionNameCheck, kind, - next_loc.beg_pos, FunctionLiteral::kAccessorOrMethod, language_mode(), - nullptr); + next_loc.beg_pos, FunctionSyntaxKind::kAccessorOrMethod, + language_mode(), nullptr); ObjectLiteralPropertyT result = factory()->NewObjectLiteralProperty( name_expression, value, @@ -2545,6 +2571,7 @@ void ParserBase<Impl>::ParseArguments( Consume(Token::LPAREN); AccumulationScope accumulation_scope(expression_scope()); + int variable_index = 0; while (peek() != Token::RPAREN) { int start_pos = peek_position(); bool is_spread = Check(Token::ELLIPSIS); @@ -2572,6 +2599,10 @@ void ParserBase<Impl>::ParseArguments( argument = factory()->NewSpread(argument, start_pos, expr_pos); } args->Add(argument); + + variable_index = + expression_scope()->SetInitializers(variable_index, peek_position()); + if (!Check(Token::COMMA)) break; } @@ -2650,6 +2681,7 @@ ParserBase<Impl>::ParseAssignmentExpressionCoverGrammar() { expression_scope()->RecordDeclarationError( Scanner::Location(lhs_beg_pos, end_position()), MessageTemplate::kInvalidPropertyBindingPattern); + expression_scope()->ValidateAsExpression(); } else if (expression->IsPattern() && op == Token::ASSIGN) { // Destructuring assignmment. if (expression->is_parenthesized()) { @@ -2777,12 +2809,11 @@ template <typename Impl> typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseConditionalExpression() { // ConditionalExpression :: - // LogicalOrExpression - // LogicalOrExpression '?' AssignmentExpression ':' AssignmentExpression - + // LogicalExpression + // LogicalExpression '?' AssignmentExpression ':' AssignmentExpression + // int pos = peek_position(); - // We start using the binary expression parser for prec >= 4 only! - ExpressionT expression = ParseBinaryExpression(4); + ExpressionT expression = ParseLogicalExpression(); return peek() == Token::CONDITIONAL ? ParseConditionalContinuation(expression, pos) : expression; @@ -2790,6 +2821,60 @@ ParserBase<Impl>::ParseConditionalExpression() { template <typename Impl> typename ParserBase<Impl>::ExpressionT +ParserBase<Impl>::ParseLogicalExpression() { + // LogicalExpression :: + // LogicalORExpression + // CoalesceExpression + + // Both LogicalORExpression and CoalesceExpression start with BitwiseOR. + // Parse for binary expressions >= 6 (BitwiseOR); + ExpressionT expression = ParseBinaryExpression(6); + if (peek() == Token::AND || peek() == Token::OR) { + // LogicalORExpression, pickup parsing where we left off. + int prec1 = Token::Precedence(peek(), accept_IN_); + expression = ParseBinaryContinuation(expression, 4, prec1); + } else if (V8_UNLIKELY(peek() == Token::NULLISH)) { + expression = ParseCoalesceExpression(expression); + } + return expression; +} + +template <typename Impl> +typename ParserBase<Impl>::ExpressionT +ParserBase<Impl>::ParseCoalesceExpression(ExpressionT expression) { + // CoalesceExpression :: + // CoalesceExpressionHead ?? BitwiseORExpression + // + // CoalesceExpressionHead :: + // CoalesceExpression + // BitwiseORExpression + + // We create a binary operation for the first nullish, otherwise collapse + // into an nary expresion. + bool first_nullish = true; + while (peek() == Token::NULLISH) { + SourceRange right_range; + SourceRangeScope right_range_scope(scanner(), &right_range); + Consume(Token::NULLISH); + int pos = peek_position(); + + // Parse BitwiseOR or higher. + ExpressionT y = ParseBinaryExpression(6); + if (first_nullish) { + expression = + factory()->NewBinaryOperation(Token::NULLISH, expression, y, pos); + impl()->RecordBinaryOperationSourceRange(expression, right_range); + first_nullish = false; + } else { + impl()->CollapseNaryExpression(&expression, y, Token::NULLISH, pos, + right_range); + } + } + return expression; +} + +template <typename Impl> +typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseConditionalContinuation(ExpressionT expression, int pos) { SourceRange then_range, else_range; @@ -3059,7 +3144,7 @@ ParserBase<Impl>::ParseLeftHandSideContinuation(ExpressionT result) { } if (has_spread) { - result = impl()->SpreadCall(result, args, pos, Call::NOT_EVAL); + result = impl()->SpreadCall(result, args, pos, Call::NOT_EVAL, false); } else { result = factory()->NewCall(result, args, pos, Call::NOT_EVAL); } @@ -3070,25 +3155,42 @@ ParserBase<Impl>::ParseLeftHandSideContinuation(ExpressionT result) { if (!Token::IsPropertyOrCall(peek())) return result; } + bool optional_chaining = false; + bool is_optional = false; do { switch (peek()) { + case Token::QUESTION_PERIOD: { + if (is_optional) { + ReportUnexpectedToken(peek()); + return impl()->FailureExpression(); + } + Consume(Token::QUESTION_PERIOD); + is_optional = true; + optional_chaining = true; + continue; + } + /* Property */ case Token::LBRACK: { Consume(Token::LBRACK); int pos = position(); AcceptINScope scope(this, true); ExpressionT index = ParseExpressionCoverGrammar(); - result = factory()->NewProperty(result, index, pos); + result = factory()->NewProperty(result, index, pos, is_optional); Expect(Token::RBRACK); break; } /* Property */ case Token::PERIOD: { + if (is_optional) { + ReportUnexpectedToken(Next()); + return impl()->FailureExpression(); + } Consume(Token::PERIOD); int pos = position(); ExpressionT key = ParsePropertyOrPrivatePropertyName(); - result = factory()->NewProperty(result, key, pos); + result = factory()->NewProperty(result, key, pos, is_optional); break; } @@ -3133,22 +3235,39 @@ ParserBase<Impl>::ParseLeftHandSideContinuation(ExpressionT result) { CheckPossibleEvalCall(result, scope()); if (has_spread) { - result = impl()->SpreadCall(result, args, pos, is_possibly_eval); + result = impl()->SpreadCall(result, args, pos, is_possibly_eval, + is_optional); } else { - result = factory()->NewCall(result, args, pos, is_possibly_eval); + result = factory()->NewCall(result, args, pos, is_possibly_eval, + is_optional); } fni_.RemoveLastFunction(); break; } - /* Call */ default: + /* Optional Property */ + if (is_optional) { + DCHECK_EQ(scanner()->current_token(), Token::QUESTION_PERIOD); + int pos = position(); + ExpressionT key = ParsePropertyOrPrivatePropertyName(); + result = factory()->NewProperty(result, key, pos, is_optional); + break; + } + if (optional_chaining) { + impl()->ReportMessageAt(scanner()->peek_location(), + MessageTemplate::kOptionalChainingNoTemplate); + return impl()->FailureExpression(); + } + /* Tagged Template */ DCHECK(Token::IsTemplate(peek())); result = ParseTemplateLiteral(result, position(), true); break; } - } while (Token::IsPropertyOrCall(peek())); + is_optional = false; + } while (is_optional || Token::IsPropertyOrCall(peek())); + if (optional_chaining) return factory()->NewOptionalChain(result); return result; } @@ -3210,6 +3329,13 @@ ParserBase<Impl>::ParseMemberWithPresentNewPrefixesExpression() { // The expression can still continue with . or [ after the arguments. return ParseMemberExpressionContinuation(result); } + + if (peek() == Token::QUESTION_PERIOD) { + impl()->ReportMessageAt(scanner()->peek_location(), + MessageTemplate::kOptionalChainingNoNew); + return impl()->FailureExpression(); + } + // NewExpression without arguments. ExpressionListT args(pointer_buffer()); return factory()->NewCallNew(result, args, new_pos); @@ -3227,8 +3353,8 @@ ParserBase<Impl>::ParseFunctionExpression() { IdentifierT name = impl()->NullIdentifier(); bool is_strict_reserved_name = Token::IsStrictReservedWord(peek()); Scanner::Location function_name_location = Scanner::Location::invalid(); - FunctionLiteral::FunctionType function_type = - FunctionLiteral::kAnonymousExpression; + FunctionSyntaxKind function_syntax_kind = + FunctionSyntaxKind::kAnonymousExpression; if (impl()->ParsingDynamicFunctionDeclaration()) { // We don't want dynamic functions to actually declare their name // "anonymous". We just want that name in the toString(). @@ -3239,14 +3365,14 @@ ParserBase<Impl>::ParseFunctionExpression() { } else if (peek_any_identifier()) { name = ParseIdentifier(function_kind); function_name_location = scanner()->location(); - function_type = FunctionLiteral::kNamedExpression; + function_syntax_kind = FunctionSyntaxKind::kNamedExpression; } FunctionLiteralT result = impl()->ParseFunctionLiteral( name, function_name_location, is_strict_reserved_name ? kFunctionNameIsStrictReserved : kFunctionNameValidityUnknown, - function_kind, function_token_position, function_type, language_mode(), - nullptr); + function_kind, function_token_position, function_syntax_kind, + language_mode(), nullptr); // TODO(verwaest): FailureFunctionLiteral? if (impl()->IsNull(result)) return impl()->FailureExpression(); return result; @@ -3332,6 +3458,11 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseSuperExpression( impl()->ReportMessage(MessageTemplate::kUnexpectedPrivateField); return impl()->FailureExpression(); } + if (peek() == Token::QUESTION_PERIOD) { + Consume(Token::QUESTION_PERIOD); + impl()->ReportMessage(MessageTemplate::kOptionalChainingNoSuper); + return impl()->FailureExpression(); + } scope->RecordSuperPropertyUsage(); UseThis(); return impl()->NewSuperPropertyReference(pos); @@ -3342,7 +3473,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseSuperExpression( // TODO(rossberg): This might not be the correct FunctionState for the // method here. expression_scope()->RecordThisUse(); - UseThis()->SetMaybeAssigned(); + UseThis(); return impl()->NewSuperCallReference(pos); } } @@ -3749,7 +3880,7 @@ ParserBase<Impl>::ParseHoistableDeclaration( FunctionLiteralT function = impl()->ParseFunctionLiteral( name, scanner()->location(), name_validity, function_kind, pos, - FunctionLiteral::kDeclaration, language_mode(), nullptr); + FunctionSyntaxKind::kDeclaration, language_mode(), nullptr); // In ES6, a function behaves as a lexical binding, except in // a script scope, or the initial scope of eval or another function. @@ -3859,7 +3990,7 @@ template <typename Impl> void ParserBase<Impl>::ParseFunctionBody( StatementListT* body, IdentifierT function_name, int pos, const FormalParametersT& parameters, FunctionKind kind, - FunctionLiteral::FunctionType function_type, FunctionBodyType body_type) { + FunctionSyntaxKind function_syntax_kind, FunctionBodyType body_type) { FunctionBodyParsingScope body_parsing_scope(impl()); if (IsResumableFunction(kind)) impl()->PrepareGeneratorVariables(); @@ -3902,9 +4033,9 @@ void ParserBase<Impl>::ParseFunctionBody( DCHECK_EQ(FunctionBodyType::kBlock, body_type); // If we are parsing the source as if it is wrapped in a function, the // source ends without a closing brace. - Token::Value closing_token = function_type == FunctionLiteral::kWrapped - ? Token::EOS - : Token::RBRACE; + Token::Value closing_token = + function_syntax_kind == FunctionSyntaxKind::kWrapped ? Token::EOS + : Token::RBRACE; if (IsAsyncGeneratorFunction(kind)) { impl()->ParseAndRewriteAsyncGeneratorFunctionBody(pos, kind, @@ -3977,7 +4108,8 @@ void ParserBase<Impl>::ParseFunctionBody( function_scope->DeclareArguments(ast_value_factory()); } - impl()->DeclareFunctionNameVar(function_name, function_type, function_scope); + impl()->DeclareFunctionNameVar(function_name, function_syntax_kind, + function_scope); inner_body.MergeInto(body); } @@ -4104,7 +4236,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral( int dummy_function_length = -1; DCHECK_NE(kind & FunctionKind::kArrowFunction, 0); bool did_preparse_successfully = impl()->SkipFunction( - nullptr, kind, FunctionLiteral::kAnonymousExpression, + nullptr, kind, FunctionSyntaxKind::kAnonymousExpression, formal_parameters.scope, &dummy_num_parameters, &dummy_function_length, &produced_preparse_data); @@ -4140,7 +4272,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral( AcceptINScope scope(this, true); ParseFunctionBody(&body, impl()->NullIdentifier(), kNoSourcePosition, parameters, kind, - FunctionLiteral::kAnonymousExpression, + FunctionSyntaxKind::kAnonymousExpression, FunctionBodyType::kBlock); CHECK(has_error()); return impl()->FailureExpression(); @@ -4150,7 +4282,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral( AcceptINScope scope(this, true); ParseFunctionBody(&body, impl()->NullIdentifier(), kNoSourcePosition, formal_parameters, kind, - FunctionLiteral::kAnonymousExpression, + FunctionSyntaxKind::kAnonymousExpression, FunctionBodyType::kBlock); expected_property_count = function_state.expected_property_count(); } @@ -4159,7 +4291,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral( has_braces = false; ParseFunctionBody(&body, impl()->NullIdentifier(), kNoSourcePosition, formal_parameters, kind, - FunctionLiteral::kAnonymousExpression, + FunctionSyntaxKind::kAnonymousExpression, FunctionBodyType::kExpression); expected_property_count = function_state.expected_property_count(); } @@ -4179,7 +4311,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral( expected_property_count, formal_parameters.num_parameters(), formal_parameters.function_length, FunctionLiteral::kNoDuplicateParameters, - FunctionLiteral::kAnonymousExpression, eager_compile_hint, + FunctionSyntaxKind::kAnonymousExpression, eager_compile_hint, formal_parameters.scope->start_position(), has_braces, function_literal_id, produced_preparse_data); @@ -4343,7 +4475,7 @@ ParserBase<Impl>::ParseAsyncFunctionLiteral() { int pos = position(); Consume(Token::FUNCTION); IdentifierT name = impl()->NullIdentifier(); - FunctionLiteral::FunctionType type = FunctionLiteral::kAnonymousExpression; + FunctionSyntaxKind syntax_kind = FunctionSyntaxKind::kAnonymousExpression; ParseFunctionFlags flags = ParseFunctionFlag::kIsAsync; if (Check(Token::MUL)) flags |= ParseFunctionFlag::kIsGenerator; @@ -4361,14 +4493,14 @@ ParserBase<Impl>::ParseAsyncFunctionLiteral() { scanner()->CurrentSymbol(ast_value_factory()) == ast_value_factory()->anonymous_string()); } else if (peek_any_identifier()) { - type = FunctionLiteral::kNamedExpression; + syntax_kind = FunctionSyntaxKind::kNamedExpression; name = ParseIdentifier(kind); } FunctionLiteralT result = impl()->ParseFunctionLiteral( name, scanner()->location(), is_strict_reserved ? kFunctionNameIsStrictReserved : kFunctionNameValidityUnknown, - kind, pos, type, language_mode(), nullptr); + kind, pos, syntax_kind, language_mode(), nullptr); if (impl()->IsNull(result)) return impl()->FailureExpression(); return result; } @@ -5742,6 +5874,7 @@ typename ParserBase<Impl>::ForStatementT ParserBase<Impl>::ParseStandardForLoop( int stmt_pos, ZonePtrList<const AstRawString>* labels, ZonePtrList<const AstRawString>* own_labels, ExpressionT* cond, StatementT* next, StatementT* body) { + CheckStackOverflow(); ForStatementT loop = factory()->NewForStatement(labels, own_labels, stmt_pos); TargetT target(this, loop); @@ -5928,15 +6061,14 @@ void ParserBase<Impl>::CheckClassMethodName(IdentifierT name, AstValueFactory* avf = ast_value_factory(); - if (is_static) { + if (impl()->IdentifierEquals(name, avf->private_constructor_string())) { + ReportMessage(MessageTemplate::kConstructorIsPrivate); + return; + } else if (is_static) { if (impl()->IdentifierEquals(name, avf->prototype_string())) { ReportMessage(MessageTemplate::kStaticPrototype); return; } - } else if (impl()->IdentifierEquals(name, - avf->private_constructor_string())) { - ReportMessage(MessageTemplate::kConstructorIsPrivate); - return; } else if (impl()->IdentifierEquals(name, avf->constructor_string())) { if (flags != ParseFunctionFlag::kIsNormal || IsAccessor(type)) { MessageTemplate msg = (flags & ParseFunctionFlag::kIsGenerator) != 0 |