Intent to Ship: RegExp duplicate named capture groups

306 views
Skip to first unread message

Shu-yu Guo

unread,
Mar 7, 2024, 6:22:54 PMMar 7
to blink-dev

Contact emails

pth...@chromium.orgs...@chromium.org

Explainer

None

Specification

https://github.com/tc39/ecma262/pull/2721

Summary

https://github.com/tc39/proposal-duplicate-named-capturing-groups



Blink component

Blink>JavaScript>Regexp

TAG review

None

TAG review status

Not applicable

Risks



Interoperability and Compatibility

This is a Stage 3 TC39 proposal. No known interop risk. No known web incompatibility risk.



Gecko: Positive Firefox uses V8's regexp engine, so it is not actually an independent implementation here.

WebKit: Shipped/Shipping (https://bugs.webkit.org/show_bug.cgi?id=252553) Stage 3 TC39 proposal.

Web developers: No signals

Other signals:

Ergonomics

No known ergonomics risks.



Activation

This is unlikely to be polyfillable since it's adding a new kind of RegExp syntax.



Security

No known security risks.



WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

None



Debuggability

Debuggable like any other JS RegExp.



Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, ChromeOS, Android, and Android WebView)?

Yes

Is this feature fully tested by web-platform-tests?

Yes

Tested in test262. https://github.com/tc39/test262/pull/3625 https://github.com/tc39/test262/pull/3706 https://github.com/tc39/test262/pull/3709



Flag name on chrome://flags

--js-regexp-duplicate-named-groups

Finch feature name

None

Non-finch justification

None

Requires code in //chrome?

False

Estimated milestones

DevTrial on desktop123
DevTrial on Android123


Anticipated spec changes

Open questions about a feature may be a source of future web compat or interop issues. Please list open issues (e.g. links to known github issues in the project for the feature specification) whose resolution may introduce web compat/interop risk (e.g., changing to naming or structure of the API in a non-backward-compatible way).

None

Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/5149208388829184

This intent message was generated by Chrome Platform Status.

Mike Taylor

unread,
Mar 8, 2024, 10:26:31 AMMar 8
to Shu-yu Guo, blink-dev

LGTM1

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAN-e9e_1DaU400sEcpB6RGv3pZg_382WduoF9MPZvK8QTPfdSQ%40mail.gmail.com.

Yoav Weiss (@Shopify)

unread,
Mar 11, 2024, 6:49:49 AMMar 11
to Mike Taylor, Shu-yu Guo, blink-dev
On Fri, Mar 8, 2024 at 4:26 PM Mike Taylor <mike...@chromium.org> wrote:

LGTM1

On 3/7/24 6:22 PM, Shu-yu Guo wrote:

What are the implications of this on regexes that already have duplicate named capture groups? Would their behavior change? 

Mike Taylor

unread,
Mar 11, 2024, 11:26:12 AMMar 11
to Yoav Weiss (@Shopify), Shu-yu Guo, blink-dev

On 3/11/24 6:49 AM, Yoav Weiss (@Shopify) wrote:



On Fri, Mar 8, 2024 at 4:26 PM Mike Taylor <mike...@chromium.org> wrote:

LGTM1

On 3/7/24 6:22 PM, Shu-yu Guo wrote:

What are the implications of this on regexes that already have duplicate named capture groups? Would their behavior change?
Shu can confirm, but my understanding is any regexes in the wild that have duplicate named capture groups today are just busted (they should throw a SyntaxError - and those are pretty hard to miss). If they do exist in the wild, they should start working, which in theory would match author intent. The risk seems very low IMHO, if it exists at all.

Shu-yu Guo

unread,
Mar 11, 2024, 12:01:01 PMMar 11
to Mike Taylor, Yoav Weiss (@Shopify), blink-dev
On Mon, Mar 11, 2024 at 8:26 AM Mike Taylor <mike...@chromium.org> wrote:

On 3/11/24 6:49 AM, Yoav Weiss (@Shopify) wrote:



On Fri, Mar 8, 2024 at 4:26 PM Mike Taylor <mike...@chromium.org> wrote:

LGTM1

On 3/7/24 6:22 PM, Shu-yu Guo wrote:

What are the implications of this on regexes that already have duplicate named capture groups? Would their behavior change?
Shu can confirm, but my understanding is any regexes in the wild that have duplicate named capture groups today are just busted (they should throw a SyntaxError - and those are pretty hard to miss). If they do exist in the wild, they should start working, which in theory would match author intent. The risk seems very low IMHO, if it exists at all.

Exactly right. This is a case of going from a SyntaxError to working, so there should be no back compat issues.

The concrete example from the explainer currently throws a SyntaxError:

```
/(?<year>[0-9]{4})-[0-9]{2}|[0-9]{2}-(?<year>[0-9]{4})/
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Invalid regular expression: /(?<year>[0-9]{4})-[0-9]{2}|[0-9]{2}-(?<year>[0-9]{4})/: Duplicate capture group name
```

Yoav Weiss (@Shopify)

unread,
Mar 11, 2024, 12:17:09 PMMar 11
to Shu-yu Guo, Mike Taylor, blink-dev
LGTM2

On Mon, Mar 11, 2024 at 5:00 PM Shu-yu Guo <s...@chromium.org> wrote:
On Mon, Mar 11, 2024 at 8:26 AM Mike Taylor <mike...@chromium.org> wrote:

On 3/11/24 6:49 AM, Yoav Weiss (@Shopify) wrote:



On Fri, Mar 8, 2024 at 4:26 PM Mike Taylor <mike...@chromium.org> wrote:

LGTM1

On 3/7/24 6:22 PM, Shu-yu Guo wrote:

What are the implications of this on regexes that already have duplicate named capture groups? Would their behavior change?
Shu can confirm, but my understanding is any regexes in the wild that have duplicate named capture groups today are just busted (they should throw a SyntaxError - and those are pretty hard to miss). If they do exist in the wild, they should start working, which in theory would match author intent. The risk seems very low IMHO, if it exists at all.

Exactly right. This is a case of going from a SyntaxError to working, so there should be no back compat issues.

Makes sense, thanks for clarifying! :)

Daniel Bratell

unread,
Mar 13, 2024, 11:13:13 AMMar 13
to Yoav Weiss (@Shopify), Shu-yu Guo, Mike Taylor, blink-dev
Reply all
Reply to author
Forward
0 new messages