Skip to content

Commit 70a3214

Browse files
Clarify why nested character classes should not be considered in the first pass
1 parent c72f92f commit 70a3214

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/compiler/scanner.ts

+3
Original file line numberDiff line numberDiff line change
@@ -2456,6 +2456,9 @@ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean
24562456
let namedCaptureGroups = false;
24572457
// Although nested character classes are allowed in Unicode Sets mode,
24582458
// an unescaped slash is nevertheless invalid even in a character class in any Unicode mode.
2459+
// This is indicated by Section 12.9.5 Regular Expression Literals of the specification,
2460+
// where nested character classes are not considered at all. (A `[` RegularExpressionClassChar
2461+
// does nothing in a RegularExpressionClass, and a `]` always closes the class.)
24592462
// Additionally, parsing nested character classes will misinterpret regexes like `/[[]/`
24602463
// as unterminated, consuming characters beyond the slash. (This even applies to `/[[]/v`,
24612464
// which should be parsed as a well-terminated regex with an incomplete character class.)

0 commit comments

Comments
 (0)