@@ -638,16 +638,21 @@ parser_parse_class_body (parser_context_t *context_p, /**< context */
638638 continue ;
639639 }
640640
641- if (is_private )
641+ bool is_constructor_literal = false;
642+
643+ if (context_p -> token .type == LEXER_LITERAL )
642644 {
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 );
645646
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+ }
647653
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+ }
651656 }
652657
653658 if (!is_static && is_constructor_literal )
@@ -809,9 +814,9 @@ parser_parse_class_body (parser_context_t *context_p, /**< context */
809814 lexer_expect_object_literal_id (context_p , ident_opts );
810815 }
811816
812- if (is_private )
817+ if (is_private && context_p -> token . type == LEXER_LITERAL )
813818 {
814- if (context_p -> token . type == LEXER_LITERAL && parser_is_constructor_literal (context_p ))
819+ if (parser_is_constructor_literal (context_p ))
815820 {
816821 parser_raise_error (context_p , PARSER_ERR_CLASS_PRIVATE_CONSTRUCTOR );
817822 }
@@ -836,9 +841,9 @@ parser_parse_class_body (parser_context_t *context_p, /**< context */
836841
837842 status_flags |= PARSER_IS_GENERATOR_FUNCTION | PARSER_DISALLOW_AWAIT_YIELD ;
838843
839- if (is_private )
844+ if (is_private && context_p -> token . type == LEXER_LITERAL )
840845 {
841- if (context_p -> token . type == LEXER_LITERAL && parser_is_constructor_literal (context_p ))
846+ if (parser_is_constructor_literal (context_p ))
842847 {
843848 parser_raise_error (context_p , PARSER_ERR_CLASS_PRIVATE_CONSTRUCTOR );
844849 }
0 commit comments