Skip to content

Commit

Permalink
Clarify why nested character classes should not be considered in the …
Browse files Browse the repository at this point in the history
…first pass
  • Loading branch information
graphemecluster committed May 28, 2024
1 parent 75a1e90 commit fdd97f4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/compiler/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2456,6 +2456,9 @@ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean
let namedCaptureGroups = false;
// Although nested character classes are allowed in Unicode Sets mode,
// an unescaped slash is nevertheless invalid even in a character class in any Unicode mode.
// This is indicated by Section 12.9.5 Regular Expression Literals of the specification,
// where nested character classes are not considered at all. (A `[` RegularExpressionClassChar
// does nothing in a RegularExpressionClass, and a `]` always closes the class.)
// Additionally, parsing nested character classes will misinterpret regexes like `/[[]/`
// as unterminated, consuming characters beyond the slash. (This even applies to `/[[]/v`,
// which should be parsed as a well-terminated regex with an incomplete character class.)
Expand Down

0 comments on commit fdd97f4

Please sign in to comment.