Skip to content

Commit 2f08117

Browse files
committed
[JSC] Don't get RegExp well-known symbol methods for primitives
https://bugs.webkit.org/show_bug.cgi?id=290684 Reviewed by NOBODY (OOPS!). This patch implements tc39/ecma262#3009. test262 has been updated for it already[1]. [1]: tc39/test262@abc22b5 * JSTests/test262/expectations.yaml: * Source/JavaScriptCore/builtins/StringPrototype.js: (match): (matchAll): (intrinsic.StringPrototypeReplaceIntrinsic.replace): (intrinsic.StringPrototypeReplaceAllIntrinsic.replaceAll): (search): (split):
1 parent 91b89e9 commit 2f08117

File tree

2 files changed

+6
-75
lines changed

2 files changed

+6
-75
lines changed

JSTests/test262/expectations.yaml

-69
Original file line numberDiff line numberDiff line change
@@ -67,75 +67,6 @@ test/built-ins/Proxy/construct/return-not-object-throws-undefined-realm.js:
6767
test/built-ins/Proxy/construct/trap-is-not-callable-realm.js:
6868
default: 'Test262Error: Expected a TypeError but got a different error constructor with the same name'
6969
strict mode: 'Test262Error: Expected a TypeError but got a different error constructor with the same name'
70-
test/built-ins/String/prototype/match/cstm-matcher-on-bigint-primitive.js:
71-
default: 'Test262Error: should not be called'
72-
strict mode: 'Test262Error: should not be called'
73-
test/built-ins/String/prototype/match/cstm-matcher-on-boolean-primitive.js:
74-
default: 'Test262Error: should not be called'
75-
strict mode: 'Test262Error: should not be called'
76-
test/built-ins/String/prototype/match/cstm-matcher-on-number-primitive.js:
77-
default: 'Test262Error: should not be called'
78-
strict mode: 'Test262Error: should not be called'
79-
test/built-ins/String/prototype/match/cstm-matcher-on-string-primitive.js:
80-
default: 'Test262Error: should not be called'
81-
strict mode: 'Test262Error: should not be called'
82-
test/built-ins/String/prototype/matchAll/cstm-matchall-on-bigint-primitive.js:
83-
default: 'Test262Error: should not be called'
84-
strict mode: 'Test262Error: should not be called'
85-
test/built-ins/String/prototype/matchAll/cstm-matchall-on-number-primitive.js:
86-
default: 'Test262Error: should not be called'
87-
strict mode: 'Test262Error: should not be called'
88-
test/built-ins/String/prototype/matchAll/cstm-matchall-on-string-primitive.js:
89-
default: 'Test262Error: should not be called'
90-
strict mode: 'Test262Error: should not be called'
91-
test/built-ins/String/prototype/replace/cstm-replace-on-bigint-primitive.js:
92-
default: 'Test262Error: should not be called'
93-
strict mode: 'Test262Error: should not be called'
94-
test/built-ins/String/prototype/replace/cstm-replace-on-boolean-primitive.js:
95-
default: 'Test262Error: should not be called'
96-
strict mode: 'Test262Error: should not be called'
97-
test/built-ins/String/prototype/replace/cstm-replace-on-number-primitive.js:
98-
default: 'Test262Error: should not be called'
99-
strict mode: 'Test262Error: should not be called'
100-
test/built-ins/String/prototype/replace/cstm-replace-on-string-primitive.js:
101-
default: 'Test262Error: should not be called'
102-
strict mode: 'Test262Error: should not be called'
103-
test/built-ins/String/prototype/replaceAll/cstm-replaceall-on-bigint-primitive.js:
104-
default: 'Test262Error: should not be called'
105-
strict mode: 'Test262Error: should not be called'
106-
test/built-ins/String/prototype/replaceAll/cstm-replaceall-on-boolean-primitive.js:
107-
default: 'Test262Error: should not be called'
108-
strict mode: 'Test262Error: should not be called'
109-
test/built-ins/String/prototype/replaceAll/cstm-replaceall-on-number-primitive.js:
110-
default: 'Test262Error: should not be called'
111-
strict mode: 'Test262Error: should not be called'
112-
test/built-ins/String/prototype/replaceAll/cstm-replaceall-on-string-primitive.js:
113-
default: 'Test262Error: should not be called'
114-
strict mode: 'Test262Error: should not be called'
115-
test/built-ins/String/prototype/search/cstm-search-on-bigint-primitive.js:
116-
default: 'Test262Error: should not be called'
117-
strict mode: 'Test262Error: should not be called'
118-
test/built-ins/String/prototype/search/cstm-search-on-boolean-primitive.js:
119-
default: 'Test262Error: should not be called'
120-
strict mode: 'Test262Error: should not be called'
121-
test/built-ins/String/prototype/search/cstm-search-on-number-primitive.js:
122-
default: 'Test262Error: should not be called'
123-
strict mode: 'Test262Error: should not be called'
124-
test/built-ins/String/prototype/search/cstm-search-on-string-primitive.js:
125-
default: 'Test262Error: should not be called'
126-
strict mode: 'Test262Error: should not be called'
127-
test/built-ins/String/prototype/split/cstm-split-on-bigint-primitive.js:
128-
default: 'Test262Error: should not be called'
129-
strict mode: 'Test262Error: should not be called'
130-
test/built-ins/String/prototype/split/cstm-split-on-boolean-primitive.js:
131-
default: 'Test262Error: should not be called'
132-
strict mode: 'Test262Error: should not be called'
133-
test/built-ins/String/prototype/split/cstm-split-on-number-primitive.js:
134-
default: 'Test262Error: should not be called'
135-
strict mode: 'Test262Error: should not be called'
136-
test/built-ins/String/prototype/split/cstm-split-on-string-primitive.js:
137-
default: 'Test262Error: should not be called'
138-
strict mode: 'Test262Error: should not be called'
13970
test/built-ins/Temporal/Duration/compare/compare-no-precision-loss.js:
14071
default: 'Test262Error: Expected SameValue(«0», «0») to be false'
14172
strict mode: 'Test262Error: Expected SameValue(«0», «0») to be false'

Source/JavaScriptCore/builtins/StringPrototype.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function match(regexp)
3232
if (@isUndefinedOrNull(this))
3333
@throwTypeError("String.prototype.match requires that |this| not be null or undefined");
3434

35-
if (!@isUndefinedOrNull(regexp)) {
35+
if (@isObject(regexp)) {
3636
var matcher = regexp.@@match;
3737
if (!@isUndefinedOrNull(matcher))
3838
return matcher.@call(regexp, this);
@@ -50,7 +50,7 @@ function matchAll(arg)
5050
if (@isUndefinedOrNull(this))
5151
@throwTypeError("String.prototype.matchAll requires |this| not to be null nor undefined");
5252

53-
if (!@isUndefinedOrNull(arg)) {
53+
if (@isObject(arg)) {
5454
if (@isRegExp(arg) && !@stringIncludesInternal.@call(@toString(arg.flags), "g"))
5555
@throwTypeError("String.prototype.matchAll argument must not be a non-global regular expression");
5656

@@ -267,7 +267,7 @@ function replace(search, replace)
267267
if (@isUndefinedOrNull(this))
268268
@throwTypeError("String.prototype.replace requires that |this| not be null or undefined");
269269

270-
if (!@isUndefinedOrNull(search)) {
270+
if (@isObject(search)) {
271271
var replacer = search.@@replace;
272272
if (!@isUndefinedOrNull(replacer)) {
273273
if (!@hasObservableSideEffectsForStringReplace(search, replacer))
@@ -289,7 +289,7 @@ function replaceAll(search, replace)
289289
if (@isUndefinedOrNull(this))
290290
@throwTypeError("String.prototype.replaceAll requires |this| not to be null nor undefined");
291291

292-
if (!@isUndefinedOrNull(search)) {
292+
if (@isObject(search)) {
293293
if (@isRegExp(search) && !@stringIncludesInternal.@call(@toString(search.flags), "g"))
294294
@throwTypeError("String.prototype.replaceAll argument must not be a non-global regular expression");
295295

@@ -313,7 +313,7 @@ function search(regexp)
313313
if (@isUndefinedOrNull(this))
314314
@throwTypeError("String.prototype.search requires that |this| not be null or undefined");
315315

316-
if (!@isUndefinedOrNull(regexp)) {
316+
if (@isObject(regexp)) {
317317
var searcher = regexp.@@search;
318318
if (!@isUndefinedOrNull(searcher))
319319
return searcher.@call(regexp, this);
@@ -331,7 +331,7 @@ function split(separator, limit)
331331
if (@isUndefinedOrNull(this))
332332
@throwTypeError("String.prototype.split requires that |this| not be null or undefined");
333333

334-
if (!@isUndefinedOrNull(separator)) {
334+
if (@isObject(separator)) {
335335
var splitter = separator.@@split;
336336
if (!@isUndefinedOrNull(splitter))
337337
return splitter.@call(separator, this, limit);

0 commit comments

Comments
 (0)