File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ const hexDigits = '0123456789abcdefABCDEF'.split('');
4545const decimalDigits = '0123456789' . split ( '' ) ;
4646const octalDigits = '01234567' . split ( '' ) ;
4747
48- const INVALID_NAMED_BACKREFERENCE_SENTINEL = { INVALID_NAMED_BACKREFERENCE_SENTINE : true } ;
48+ const INVALID_NAMED_BACKREFERENCE_SENTINEL = { } ;
4949
5050function isIdentifierStart ( ch ) {
5151 return ch < 128 ? idStartBool [ ch ] : idStartLargeRegex . test ( String . fromCodePoint ( ch ) ) ;
@@ -669,7 +669,14 @@ const acceptCharacterClass = backtrackOnFailure(state => {
669669 return { matched : true , value : character . charCodeAt ( 0 ) % 32 } ;
670670 } ) ,
671671 acceptCharacterClassEscape ,
672- acceptCharacterEscape
672+ acceptCharacterEscape ,
673+ // We special-case `\k` because `acceptCharacterEscape` rejects `\k` unconditionally,
674+ // deferring `\k` to acceptGroupNameBackreference, which is not called here.
675+ // See also https://github.com/tc39/ecma262/issues/2037. This code takes the route of
676+ // making it unconditionally legal, rather than legal only in the absence of a group name.
677+ subState => {
678+ return { matched : ! subState . unicode && ! ! subState . eat ( 'k' ) , value : 107 } ;
679+ } ,
673680 ) ;
674681
675682 const acceptClassAtomNoDash = localState => {
Original file line number Diff line number Diff line change @@ -184,6 +184,11 @@ suite('Parser', () => {
184184 /\k</
185185 /\k<x/
186186 /\k<x>/
187+ /[\k]/
188+ /[\k<]/
189+ /[\k<x]/
190+ /[\k<x>]/
191+ /[\k](?<x>)/
187192 /[${ '\\' } 1-${ '\\' } 127]/
188193 /[${ '\\' } 128-9]/
189194 /[${ '\\' } 99-${ '\\' } 100]/
@@ -229,6 +234,7 @@ suite('Parser', () => {
229234 /${ '\\u' } {ZZ}/u
230235 /5{5,1G}/u
231236 /\k/u
237+ /[\k]/u
232238 /\k<X>/u
233239 /(?<X>)(?<X>)/
234240 /\p{ASCIIII}/u
You can’t perform that action at this time.
0 commit comments