WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
205783
RegExp.prototype[Symbol.replace] does not support named capture groups
https://bugs.webkit.org/show_bug.cgi?id=205783
Summary
RegExp.prototype[Symbol.replace] does not support named capture groups
Alexey Shvayka
Reported
2020-01-05 18:01:30 PST
While String.prototype.replace() works as expected with named capture groups, slow path is not implemented. Test case: /(?<a>.)/[Symbol.replace]("b", "$<a>") Expected: "b" Actual: "$<a>" ECMA262:
https://tc39.es/ecma262/#sec-regexp.prototype-@@replace
(step 14.j) Test262:
https://test262.report/browse/built-ins/RegExp/named-groups/groups-object-subclass-sans.js
https://test262.report/browse/built-ins/RegExp/named-groups/groups-object-subclass.js
Attachments
Patch
(6.47 KB, patch)
2020-01-05 19:25 PST
,
Alexey Shvayka
ross.kirsling
: review+
Details
Formatted Diff
Diff
Patch
(6.48 KB, patch)
2020-01-07 12:31 PST
,
Alexey Shvayka
no flags
Details
Formatted Diff
Diff
Patch
(6.47 KB, patch)
2020-01-07 22:09 PST
,
Alexey Shvayka
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Alexey Shvayka
Comment 1
2020-01-05 19:25:26 PST
Created
attachment 386803
[details]
Patch
Ross Kirsling
Comment 2
2020-01-06 15:43:14 PST
Comment on
attachment 386803
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=386803&action=review
r=me with nits
> Source/JavaScriptCore/ChangeLog:10 > + (step 14.j of
https://tc39.es/ecma262/#sec-regexp.prototype-@@replace
)
Probably better to indicate that it's not just 14.j but 14.j-l.
> Source/JavaScriptCore/builtins/RegExpPrototype.js:360 > + namedCaptures = @toObject(namedCaptures, "RegExp.prototype[Symbol.replace] requires result.group not be null or undefined");
Hmm, this is meant to be `result.groups`, right? Though that still seems a bit problematic since `result` is an internal name. And I guess we've verified that it's not undefined. How about this? "RegExp.prototype.@@replace does not allow matches to have a null 'groups' property."
Alexey Shvayka
Comment 3
2020-01-07 12:31:00 PST
Created
attachment 387020
[details]
Patch Set reviewer, tweak ChangeLog and error message.
Alexey Shvayka
Comment 4
2020-01-07 12:33:59 PST
(In reply to Ross Kirsling from
comment #2
)
> How about this? > "RegExp.prototype.@@replace does not allow matches to have a null 'groups' > property."
Thank you for review, I went with "RegExp.prototype[Symbol.replace] requires 'groups' property of a match not be null" to avoid @@ notation (because of
https://github.com/tc39/ecma262/pull/1314
) and for consistency with other @toObject error messages.
Ross Kirsling
Comment 5
2020-01-07 16:25:21 PST
Guess there's a rebase conflict here.
Alexey Shvayka
Comment 6
2020-01-07 22:09:22 PST
Created
attachment 387075
[details]
Patch Rebase patch.
WebKit Commit Bot
Comment 7
2020-01-08 05:48:28 PST
Comment on
attachment 387075
[details]
Patch Clearing flags on attachment: 387075 Committed
r254195
: <
https://trac.webkit.org/changeset/254195
>
WebKit Commit Bot
Comment 8
2020-01-08 05:48:30 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 9
2020-01-08 05:49:14 PST
<
rdar://problem/58406622
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug