summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2025-05-24 13:01:50 +0200
committerFabrice Bellard <fabrice@bellard.org>2025-05-24 13:01:50 +0200
commit3d92a9d30cbb43fc0685c44fc3fb9727a2b4be7c (patch)
treea10a639d4f892d0c6977fabf53b9890903bfa10a
parent02a2643142a0522e9e2d0d60df19e72daa84bbc3 (diff)
downloadquickjs-3d92a9d30cbb43fc0685c44fc3fb9727a2b4be7c.tar.gz
quickjs-3d92a9d30cbb43fc0685c44fc3fb9727a2b4be7c.zip
new keyword cannot be used with an optional chain
-rw-r--r--quickjs.c2
-rw-r--r--test262_errors.txt1
2 files changed, 2 insertions, 1 deletions
diff --git a/quickjs.c b/quickjs.c
index ac4f2aa..42c8d4e 100644
--- a/quickjs.c
+++ b/quickjs.c
@@ -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))
diff --git a/test262_errors.txt b/test262_errors.txt
index 6cac22d..7e086f6 100644
--- a/test262_errors.txt
+++ b/test262_errors.txt
@@ -30,7 +30,6 @@ test262/test/staging/sm/class/boundFunctionSubclassing.js:12: Test262Error: Expe
test262/test/staging/sm/class/compPropNames.js:26: Error: Expected syntax error: ({[1, 2]: 3})
test262/test/staging/sm/class/strictExecution.js:32: Error: Assertion failed: expected exception TypeError, no exception thrown
test262/test/staging/sm/class/superPropOrdering.js:83: Error: Assertion failed: expected exception TypeError, no exception thrown
-test262/test/staging/sm/expressions/optional-chain.js:25: Error: Assertion failed: expected exception SyntaxError, no exception thrown
test262/test/staging/sm/expressions/short-circuit-compound-assignment-const.js:97: TypeError: 'a' is read-only
test262/test/staging/sm/expressions/short-circuit-compound-assignment-tdz.js:23: Error: Assertion failed: expected exception ReferenceError, got TypeError: 'a' is read-only
test262/test/staging/sm/extensions/TypedArray-set-object-funky-length-detaches.js:55: RangeError: invalid array length