这是indexloc提供的服务,不要输入任何密码
Skip to content

regular_expression: Improve ES2025 proposal-duplicate-named-capturing-groups logic #6358

@leaysgur

Description

@leaysgur

Done in #6847 , but there is room for performance improvement.

We want to keep the code as simple as possible and process the current 2 loops in 1 loop for duplicates detection.


https://github.com/tc39/proposal-duplicate-named-capturing-groups
https://tc39.es/ecma262/#sec-mightbothparticipate

For now, /(?<a>.)(?<a>.)/ is invalid syntax, name a is duplicated.

With this change, we can use the same name if they are splitted by | and in the same Disjunction like /(?<a>.)|(?<a>.)/.

But it still not allowed in some cases like /(?<n>|(?<n>))/, /(?<n>(?<n>)|)/, /((?<n>)|(?<n>))(?<n>)/, etc...

You need to track nesting level and | to mange scope.

TODOs

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory - New feature or requestgood first issueExperience Level - Good for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions