@@ -638,16 +638,23 @@ parser_parse_class_body (parser_context_t *context_p, /**< context */
638
638
continue ;
639
639
}
640
640
641
- if (is_private )
642
- {
643
- parser_check_duplicated_private_field (context_p , SCANNER_PRIVATE_FIELD_PROPERTY_GETTER_SETTER );
644
- }
645
-
646
- bool is_constructor_literal = context_p -> token .type == LEXER_LITERAL && parser_is_constructor_literal (context_p );
641
+ bool is_constructor_literal = false;
647
642
648
- if (is_private && is_constructor_literal && lexer_check_next_character ( context_p , LIT_CHAR_LEFT_PAREN ) )
643
+ if (context_p -> token . type == LEXER_LITERAL )
649
644
{
650
- parser_raise_error (context_p , PARSER_ERR_CLASS_PRIVATE_CONSTRUCTOR );
645
+ if (parser_is_constructor_literal (context_p ))
646
+ {
647
+ is_constructor_literal = true;
648
+
649
+ if (is_private && lexer_check_next_character (context_p , LIT_CHAR_LEFT_PAREN ))
650
+ {
651
+ parser_raise_error (context_p , PARSER_ERR_CLASS_PRIVATE_CONSTRUCTOR );
652
+ }
653
+ }
654
+ else
655
+ {
656
+ parser_check_duplicated_private_field (context_p , SCANNER_PRIVATE_FIELD_PROPERTY_GETTER_SETTER );
657
+ }
651
658
}
652
659
653
660
if (!is_static && is_constructor_literal )
@@ -809,9 +816,9 @@ parser_parse_class_body (parser_context_t *context_p, /**< context */
809
816
lexer_expect_object_literal_id (context_p , ident_opts );
810
817
}
811
818
812
- if (is_private )
819
+ if (is_private && context_p -> token . type == LEXER_LITERAL )
813
820
{
814
- if (context_p -> token . type == LEXER_LITERAL && parser_is_constructor_literal (context_p ))
821
+ if (parser_is_constructor_literal (context_p ))
815
822
{
816
823
parser_raise_error (context_p , PARSER_ERR_CLASS_PRIVATE_CONSTRUCTOR );
817
824
}
@@ -836,9 +843,9 @@ parser_parse_class_body (parser_context_t *context_p, /**< context */
836
843
837
844
status_flags |= PARSER_IS_GENERATOR_FUNCTION | PARSER_DISALLOW_AWAIT_YIELD ;
838
845
839
- if (is_private )
846
+ if (is_private && context_p -> token . type == LEXER_LITERAL )
840
847
{
841
- if (context_p -> token . type == LEXER_LITERAL && parser_is_constructor_literal (context_p ))
848
+ if (parser_is_constructor_literal (context_p ))
842
849
{
843
850
parser_raise_error (context_p , PARSER_ERR_CLASS_PRIVATE_CONSTRUCTOR );
844
851
}
0 commit comments