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('');
45
45
const decimalDigits = '0123456789' . split ( '' ) ;
46
46
const octalDigits = '01234567' . split ( '' ) ;
47
47
48
- const INVALID_NAMED_BACKREFERENCE_SENTINEL = { INVALID_NAMED_BACKREFERENCE_SENTINE : true } ;
48
+ const INVALID_NAMED_BACKREFERENCE_SENTINEL = { } ;
49
49
50
50
function isIdentifierStart ( ch ) {
51
51
return ch < 128 ? idStartBool [ ch ] : idStartLargeRegex . test ( String . fromCodePoint ( ch ) ) ;
@@ -669,7 +669,14 @@ const acceptCharacterClass = backtrackOnFailure(state => {
669
669
return { matched : true , value : character . charCodeAt ( 0 ) % 32 } ;
670
670
} ) ,
671
671
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
+ } ,
673
680
) ;
674
681
675
682
const acceptClassAtomNoDash = localState => {
Original file line number Diff line number Diff line change @@ -184,6 +184,11 @@ suite('Parser', () => {
184
184
/\k</
185
185
/\k<x/
186
186
/\k<x>/
187
+ /[\k]/
188
+ /[\k<]/
189
+ /[\k<x]/
190
+ /[\k<x>]/
191
+ /[\k](?<x>)/
187
192
/[${ '\\' } 1-${ '\\' } 127]/
188
193
/[${ '\\' } 128-9]/
189
194
/[${ '\\' } 99-${ '\\' } 100]/
@@ -229,6 +234,7 @@ suite('Parser', () => {
229
234
/${ '\\u' } {ZZ}/u
230
235
/5{5,1G}/u
231
236
/\k/u
237
+ /[\k]/u
232
238
/\k<X>/u
233
239
/(?<X>)(?<X>)/
234
240
/\p{ASCIIII}/u
You can’t perform that action at this time.
0 commit comments