@@ -620,26 +620,32 @@ class ParserBase {
620620 return instance_members_scope != nullptr ;
621621 }
622622
623- DeclarationScope* EnsureStaticElementsScope (ParserBase* parser,
624- int beg_pos ) {
623+ DeclarationScope* EnsureStaticElementsScope (ParserBase* parser, int beg_pos,
624+ int info_id ) {
625625 if (!has_static_elements ()) {
626626 static_elements_scope = parser->NewFunctionScope (
627627 FunctionKind::kClassStaticInitializerFunction );
628628 static_elements_scope->SetLanguageMode (LanguageMode::kStrict );
629629 static_elements_scope->set_start_position (beg_pos);
630- static_elements_function_id = parser->GetNextInfoId ();
630+ static_elements_function_id = info_id;
631+ // Actually consume the id. The id that was passed in might be an
632+ // earlier id in case of computed property names.
633+ parser->GetNextInfoId ();
631634 }
632635 return static_elements_scope;
633636 }
634637
635638 DeclarationScope* EnsureInstanceMembersScope (ParserBase* parser,
636- int beg_pos) {
639+ int beg_pos, int info_id ) {
637640 if (!has_instance_members ()) {
638641 instance_members_scope = parser->NewFunctionScope (
639642 FunctionKind::kClassMembersInitializerFunction );
640643 instance_members_scope->SetLanguageMode (LanguageMode::kStrict );
641644 instance_members_scope->set_start_position (beg_pos);
642- instance_members_function_id = parser->GetNextInfoId ();
645+ instance_members_function_id = info_id;
646+ // Actually consume the id. The id that was passed in might be an
647+ // earlier id in case of computed property names.
648+ parser->GetNextInfoId ();
643649 }
644650 return instance_members_scope;
645651 }
@@ -1321,7 +1327,7 @@ class ParserBase {
13211327 ParseFunctionFlags flags, bool is_static,
13221328 bool * has_seen_constructor);
13231329 ExpressionT ParseMemberInitializer (ClassInfo* class_info, int beg_pos,
1324- bool is_static);
1330+ int info_id, bool is_static);
13251331 BlockT ParseClassStaticBlock (ClassInfo* class_info);
13261332 ObjectLiteralPropertyT ParseObjectPropertyDefinition (
13271333 ParsePropertyInfo* prop_info, bool * has_seen_proto);
@@ -2624,6 +2630,8 @@ ParserBase<Impl>::ParseClassPropertyDefinition(ClassInfo* class_info,
26242630 DCHECK_NOT_NULL (class_info);
26252631 DCHECK_EQ (prop_info->position , PropertyPosition::kClassLiteral );
26262632
2633+ int next_info_id = PeekNextInfoId ();
2634+
26272635 Token::Value name_token = peek ();
26282636 int property_beg_pos = peek_position ();
26292637 int name_token_position = property_beg_pos;
@@ -2667,12 +2675,18 @@ ParserBase<Impl>::ParseClassPropertyDefinition(ClassInfo* class_info,
26672675 // field.
26682676 DCHECK_IMPLIES (prop_info->is_computed_name , !prop_info->is_private );
26692677
2670- if (!prop_info->is_computed_name ) {
2678+ if (prop_info->is_computed_name ) {
2679+ if (!has_error () && next_info_id != PeekNextInfoId () &&
2680+ !(prop_info->is_static ? class_info->has_static_elements ()
2681+ : class_info->has_instance_members ())) {
2682+ impl ()->ReindexComputedMemberName (name_expression);
2683+ }
2684+ } else {
26712685 CheckClassFieldName (prop_info->name , prop_info->is_static );
26722686 }
26732687
2674- ExpressionT value = ParseMemberInitializer (class_info, property_beg_pos,
2675- prop_info->is_static );
2688+ ExpressionT value = ParseMemberInitializer (
2689+ class_info, property_beg_pos, next_info_id, prop_info->is_static );
26762690 ExpectSemicolon ();
26772691
26782692 ClassLiteralPropertyT result;
@@ -2786,11 +2800,12 @@ ParserBase<Impl>::ParseClassPropertyDefinition(ClassInfo* class_info,
27862800
27872801template <typename Impl>
27882802typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseMemberInitializer(
2789- ClassInfo* class_info, int beg_pos, bool is_static) {
2803+ ClassInfo* class_info, int beg_pos, int info_id, bool is_static) {
27902804 FunctionParsingScope body_parsing_scope (impl ());
27912805 DeclarationScope* initializer_scope =
2792- is_static ? class_info->EnsureStaticElementsScope (this , beg_pos)
2793- : class_info->EnsureInstanceMembersScope (this , beg_pos);
2806+ is_static
2807+ ? class_info->EnsureStaticElementsScope (this , beg_pos, info_id)
2808+ : class_info->EnsureInstanceMembersScope (this , beg_pos, info_id);
27942809
27952810 if (Check (Token::kAssign )) {
27962811 FunctionState initializer_state (&function_state_, &scope_,
@@ -2811,7 +2826,7 @@ typename ParserBase<Impl>::BlockT ParserBase<Impl>::ParseClassStaticBlock(
28112826 Consume (Token::kStatic );
28122827
28132828 DeclarationScope* initializer_scope =
2814- class_info->EnsureStaticElementsScope (this , position ());
2829+ class_info->EnsureStaticElementsScope (this , position (), PeekNextInfoId () );
28152830
28162831 FunctionState initializer_state (&function_state_, &scope_, initializer_scope);
28172832 FunctionParsingScope body_parsing_scope (impl ());
0 commit comments