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