From c73a435f365e5250dd529cde00675528d7609edf Mon Sep 17 00:00:00 2001 From: Fabrice Bellard Date: Thu, 11 Dec 2025 19:27:19 +0100 Subject: [PATCH] Don't call well-known Symbol methods for RegExp on primitive values --- TODO | 2 +- quickjs.c | 6 +++--- test262.conf | 48 ------------------------------------------------ 3 files changed, 4 insertions(+), 52 deletions(-) diff --git a/TODO b/TODO index 9ddeaad..a0cb604 100644 --- a/TODO +++ b/TODO @@ -63,4 +63,4 @@ Test262o: 0/11262 errors, 463 excluded Test262o commit: 7da91bceb9ce7613f87db47ddd1292a2dda58b42 (es5-tests branch) Test262: -Result: 66/83295 errors, 2590 excluded, 5767 skipped +Result: 66/83341 errors, 2567 excluded, 5767 skipped diff --git a/quickjs.c b/quickjs.c index 3e88d7b..f86379f 100644 --- a/quickjs.c +++ b/quickjs.c @@ -45142,7 +45142,7 @@ static JSValue js_string_match(JSContext *ctx, JSValueConst this_val, if (JS_IsUndefined(O) || JS_IsNull(O)) return JS_ThrowTypeError(ctx, "cannot convert to object"); - if (!JS_IsUndefined(regexp) && !JS_IsNull(regexp)) { + if (JS_IsObject(regexp)) { matcher = JS_GetProperty(ctx, regexp, atom); if (JS_IsException(matcher)) return JS_EXCEPTION; @@ -45322,7 +45322,7 @@ static JSValue js_string_replace(JSContext *ctx, JSValueConst this_val, replaceValue_str = JS_UNDEFINED; repl_str = JS_UNDEFINED; - if (!JS_IsUndefined(searchValue) && !JS_IsNull(searchValue)) { + if (JS_IsObject(searchValue)) { JSValue replacer; if (is_replaceAll) { if (check_regexp_g_flag(ctx, searchValue) < 0) @@ -45433,7 +45433,7 @@ static JSValue js_string_split(JSContext *ctx, JSValueConst this_val, A = JS_UNDEFINED; R = JS_UNDEFINED; - if (!JS_IsUndefined(separator) && !JS_IsNull(separator)) { + if (JS_IsObject(separator)) { JSValue splitter; splitter = JS_GetProperty(ctx, separator, JS_ATOM_Symbol_split); if (JS_IsException(splitter)) diff --git a/test262.conf b/test262.conf index 308f245..aa76e63 100644 --- a/test262.conf +++ b/test262.conf @@ -255,54 +255,6 @@ test262/test/built-ins/ThrowTypeError/unique-per-realm-function-proto.js #test262/test/built-ins/RegExp/CharacterClassEscapes/ #test262/test/built-ins/RegExp/property-escapes/ -# not yet in official specification -test262/test/built-ins/String/prototype/match/cstm-matcher-on-bigint-primitive.js -test262/test/built-ins/String/prototype/match/cstm-matcher-on-bigint-primitive.js -test262/test/built-ins/String/prototype/match/cstm-matcher-on-boolean-primitive.js -test262/test/built-ins/String/prototype/match/cstm-matcher-on-boolean-primitive.js -test262/test/built-ins/String/prototype/match/cstm-matcher-on-number-primitive.js -test262/test/built-ins/String/prototype/match/cstm-matcher-on-number-primitive.js -test262/test/built-ins/String/prototype/match/cstm-matcher-on-string-primitive.js -test262/test/built-ins/String/prototype/match/cstm-matcher-on-string-primitive.js -test262/test/built-ins/String/prototype/matchAll/cstm-matchall-on-bigint-primitive.js -test262/test/built-ins/String/prototype/matchAll/cstm-matchall-on-bigint-primitive.js -test262/test/built-ins/String/prototype/matchAll/cstm-matchall-on-number-primitive.js -test262/test/built-ins/String/prototype/matchAll/cstm-matchall-on-number-primitive.js -test262/test/built-ins/String/prototype/matchAll/cstm-matchall-on-string-primitive.js -test262/test/built-ins/String/prototype/matchAll/cstm-matchall-on-string-primitive.js -test262/test/built-ins/String/prototype/replace/cstm-replace-on-bigint-primitive.js -test262/test/built-ins/String/prototype/replace/cstm-replace-on-bigint-primitive.js -test262/test/built-ins/String/prototype/replace/cstm-replace-on-boolean-primitive.js -test262/test/built-ins/String/prototype/replace/cstm-replace-on-boolean-primitive.js -test262/test/built-ins/String/prototype/replace/cstm-replace-on-number-primitive.js -test262/test/built-ins/String/prototype/replace/cstm-replace-on-number-primitive.js -test262/test/built-ins/String/prototype/replace/cstm-replace-on-string-primitive.js -test262/test/built-ins/String/prototype/replace/cstm-replace-on-string-primitive.js -test262/test/built-ins/String/prototype/replaceAll/cstm-replaceall-on-bigint-primitive.js -test262/test/built-ins/String/prototype/replaceAll/cstm-replaceall-on-bigint-primitive.js -test262/test/built-ins/String/prototype/replaceAll/cstm-replaceall-on-boolean-primitive.js -test262/test/built-ins/String/prototype/replaceAll/cstm-replaceall-on-boolean-primitive.js -test262/test/built-ins/String/prototype/replaceAll/cstm-replaceall-on-number-primitive.js -test262/test/built-ins/String/prototype/replaceAll/cstm-replaceall-on-number-primitive.js -test262/test/built-ins/String/prototype/replaceAll/cstm-replaceall-on-string-primitive.js -test262/test/built-ins/String/prototype/replaceAll/cstm-replaceall-on-string-primitive.js -test262/test/built-ins/String/prototype/search/cstm-search-on-bigint-primitive.js -test262/test/built-ins/String/prototype/search/cstm-search-on-bigint-primitive.js -test262/test/built-ins/String/prototype/search/cstm-search-on-boolean-primitive.js -test262/test/built-ins/String/prototype/search/cstm-search-on-boolean-primitive.js -test262/test/built-ins/String/prototype/search/cstm-search-on-number-primitive.js -test262/test/built-ins/String/prototype/search/cstm-search-on-number-primitive.js -test262/test/built-ins/String/prototype/search/cstm-search-on-string-primitive.js -test262/test/built-ins/String/prototype/search/cstm-search-on-string-primitive.js -test262/test/built-ins/String/prototype/split/cstm-split-on-bigint-primitive.js -test262/test/built-ins/String/prototype/split/cstm-split-on-bigint-primitive.js -test262/test/built-ins/String/prototype/split/cstm-split-on-boolean-primitive.js -test262/test/built-ins/String/prototype/split/cstm-split-on-boolean-primitive.js -test262/test/built-ins/String/prototype/split/cstm-split-on-number-primitive.js -test262/test/built-ins/String/prototype/split/cstm-split-on-number-primitive.js -test262/test/built-ins/String/prototype/split/cstm-split-on-string-primitive.js -test262/test/built-ins/String/prototype/split/cstm-split-on-string-primitive.js - #################################### # staging tests