new keyword cannot be used with an optional chain

This commit is contained in:
Fabrice Bellard
2025-05-24 13:01:50 +02:00
parent 02a2643142
commit 3d92a9d30c
2 changed files with 2 additions and 1 deletions

View File

@@ -25660,6 +25660,8 @@ static __exception int js_parse_postfix_expr(JSParseState *s, int parse_flags)
BOOL has_optional_chain = FALSE;
if (s->token.val == TOK_QUESTION_MARK_DOT) {
if ((parse_flags & PF_POSTFIX_CALL) == 0)
return js_parse_error(s, "new keyword cannot be used with an optional chain");
op_token_ptr = s->token.ptr;
/* optional chaining */
if (next_token(s))