Summary
ParseGroupName in the regex compiler accepts any characters until > without validating that the name follows the ECMAScript IdentifierName grammar.
Why
Per ES2026 §22.2.1, the GroupName in (?<name>...) and \k<name> must be a valid IdentifierName: starting with IdentifierStart (letter, _, $, or \u escape), followed by IdentifierPart characters. Empty names, names starting with digits, and names containing hyphens should all be SyntaxErrors.
Current behavior
new RegExp('(?<1>a)') and new RegExp('(?<a-b>a)') are silently accepted.
Expected behavior
Both throw SyntaxError.
Scope notes
- Source:
Goccia.RegExp.Compiler.pas ParseGroupName
- Not a regression from this PR — the old TRegExpr engine handled named groups via string preprocessing without grammar validation either
- 4 test262 named-groups tests reference this:
non-unicode-property-names-valid.js, non-unicode-property-names.js, unicode-property-names-valid.js, unicode-property-names.js
Summary
ParseGroupNamein the regex compiler accepts any characters until>without validating that the name follows the ECMAScript IdentifierName grammar.Why
Per ES2026 §22.2.1, the GroupName in
(?<name>...)and\k<name>must be a valid IdentifierName: starting with IdentifierStart (letter,_,$, or\uescape), followed by IdentifierPart characters. Empty names, names starting with digits, and names containing hyphens should all be SyntaxErrors.Current behavior
new RegExp('(?<1>a)')andnew RegExp('(?<a-b>a)')are silently accepted.Expected behavior
Both throw SyntaxError.
Scope notes
Goccia.RegExp.Compiler.pasParseGroupNamenon-unicode-property-names-valid.js,non-unicode-property-names.js,unicode-property-names-valid.js,unicode-property-names.js