Skip to content

Commit 3d92a9d

Browse files
author
Fabrice Bellard
committed
new keyword cannot be used with an optional chain
1 parent 02a2643 commit 3d92a9d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

quickjs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25660,6 +25660,8 @@ static __exception int js_parse_postfix_expr(JSParseState *s, int parse_flags)
2566025660
BOOL has_optional_chain = FALSE;
2566125661

2566225662
if (s->token.val == TOK_QUESTION_MARK_DOT) {
25663+
if ((parse_flags & PF_POSTFIX_CALL) == 0)
25664+
return js_parse_error(s, "new keyword cannot be used with an optional chain");
2566325665
op_token_ptr = s->token.ptr;
2566425666
/* optional chaining */
2566525667
if (next_token(s))

test262_errors.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ test262/test/staging/sm/class/boundFunctionSubclassing.js:12: Test262Error: Expe
3030
test262/test/staging/sm/class/compPropNames.js:26: Error: Expected syntax error: ({[1, 2]: 3})
3131
test262/test/staging/sm/class/strictExecution.js:32: Error: Assertion failed: expected exception TypeError, no exception thrown
3232
test262/test/staging/sm/class/superPropOrdering.js:83: Error: Assertion failed: expected exception TypeError, no exception thrown
33-
test262/test/staging/sm/expressions/optional-chain.js:25: Error: Assertion failed: expected exception SyntaxError, no exception thrown
3433
test262/test/staging/sm/expressions/short-circuit-compound-assignment-const.js:97: TypeError: 'a' is read-only
3534
test262/test/staging/sm/expressions/short-circuit-compound-assignment-tdz.js:23: Error: Assertion failed: expected exception ReferenceError, got TypeError: 'a' is read-only
3635
test262/test/staging/sm/extensions/TypedArray-set-object-funky-length-detaches.js:55: RangeError: invalid array length

0 commit comments

Comments
 (0)