RegExp syntax checking performance (#58339)

Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
This commit is contained in:
Ron Buckton
2024-04-29 15:12:36 -04:00
committed by GitHub
parent d2ad3ca035
commit cd566bad95
7 changed files with 1099 additions and 1041 deletions
+1 -1
View File
@@ -31379,7 +31379,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
function checkGrammarRegularExpressionLiteral(node: RegularExpressionLiteral) {
const sourceFile = getSourceFileOfNode(node);
if (!hasParseDiagnostics(sourceFile)) {
if (!hasParseDiagnostics(sourceFile) && !node.isUnterminated) {
let lastError: DiagnosticWithLocation | undefined;
scanner ??= createScanner(ScriptTarget.ESNext, /*skipTrivia*/ true);
scanner.setScriptTarget(sourceFile.languageVersion);
+1 -1
View File
@@ -1733,7 +1733,7 @@
"category": "Error",
"code": 1519
},
"Expected a class set oprand.": {
"Expected a class set operand.": {
"category": "Error",
"code": 1520
},
+1066 -1009
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -7630,6 +7630,7 @@ export type CommandLineOption = CommandLineOptionOfCustomType | CommandLineOptio
// dprint-ignore
/** @internal */
export const enum CharacterCodes {
EOF = -1,
nullCharacter = 0,
maxAsciiCharacter = 0x7F,
@@ -157,8 +157,8 @@ regularExpressionScanning.ts(37,61): error TS1508: Unexpected '}'. Did you mean
regularExpressionScanning.ts(37,63): error TS1517: Range out of order in character class.
regularExpressionScanning.ts(37,76): error TS1535: This character cannot be escaped in a regular expression.
regularExpressionScanning.ts(38,8): error TS1005: '--' expected.
regularExpressionScanning.ts(38,9): error TS1520: Expected a class set oprand.
regularExpressionScanning.ts(38,11): error TS1520: Expected a class set oprand.
regularExpressionScanning.ts(38,9): error TS1520: Expected a class set operand.
regularExpressionScanning.ts(38,11): error TS1520: Expected a class set operand.
regularExpressionScanning.ts(38,12): error TS1005: '--' expected.
regularExpressionScanning.ts(38,15): error TS1522: A character class must not contain a reserved double punctuator. Did you mean to escape it with backslash?
regularExpressionScanning.ts(38,20): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead.
@@ -166,15 +166,15 @@ regularExpressionScanning.ts(38,28): error TS1519: Operators must not be mixed w
regularExpressionScanning.ts(38,40): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead.
regularExpressionScanning.ts(38,47): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead.
regularExpressionScanning.ts(38,49): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead.
regularExpressionScanning.ts(38,50): error TS1520: Expected a class set oprand.
regularExpressionScanning.ts(38,50): error TS1520: Expected a class set operand.
regularExpressionScanning.ts(38,55): error TS1511: '\q' is only available inside character class.
regularExpressionScanning.ts(38,57): error TS1508: Unexpected '{'. Did you mean to escape it with backslash?
regularExpressionScanning.ts(38,61): error TS1508: Unexpected '}'. Did you mean to escape it with backslash?
regularExpressionScanning.ts(38,66): error TS1508: Unexpected '-'. Did you mean to escape it with backslash?
regularExpressionScanning.ts(38,67): error TS1005: '--' expected.
regularExpressionScanning.ts(38,70): error TS1520: Expected a class set oprand.
regularExpressionScanning.ts(38,70): error TS1520: Expected a class set operand.
regularExpressionScanning.ts(38,75): error TS1508: Unexpected '&'. Did you mean to escape it with backslash?
regularExpressionScanning.ts(38,85): error TS1520: Expected a class set oprand.
regularExpressionScanning.ts(38,85): error TS1520: Expected a class set operand.
regularExpressionScanning.ts(38,87): error TS1501: This regular expression flag is only available when targeting 'esnext' or later.
regularExpressionScanning.ts(39,56): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead.
regularExpressionScanning.ts(39,67): error TS1005: '&&' expected.
@@ -561,9 +561,9 @@ regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag
!!! error TS1005: '--' expected.
!!! error TS1520: Expected a class set oprand.
!!! error TS1520: Expected a class set operand.
!!! error TS1520: Expected a class set oprand.
!!! error TS1520: Expected a class set operand.
!!! error TS1005: '--' expected.
~~
@@ -579,7 +579,7 @@ regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag
~
!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead.
!!! error TS1520: Expected a class set oprand.
!!! error TS1520: Expected a class set operand.
~~
!!! error TS1511: '\q' is only available inside character class.
~
@@ -591,11 +591,11 @@ regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag
!!! error TS1005: '--' expected.
!!! error TS1520: Expected a class set oprand.
!!! error TS1520: Expected a class set operand.
~
!!! error TS1508: Unexpected '&'. Did you mean to escape it with backslash?
!!! error TS1520: Expected a class set oprand.
!!! error TS1520: Expected a class set operand.
~
!!! error TS1501: This regular expression flag is only available when targeting 'esnext' or later.
/[[^\P{Decimal_Number}&&[0-9]]&&\p{L}&&\p{ID_Continue}--\p{ASCII}\p{CWCF}]/v,
@@ -164,8 +164,8 @@ regularExpressionScanning.ts(37,63): error TS1517: Range out of order in charact
regularExpressionScanning.ts(37,76): error TS1535: This character cannot be escaped in a regular expression.
regularExpressionScanning.ts(37,87): error TS1501: This regular expression flag is only available when targeting 'es6' or later.
regularExpressionScanning.ts(38,8): error TS1005: '--' expected.
regularExpressionScanning.ts(38,9): error TS1520: Expected a class set oprand.
regularExpressionScanning.ts(38,11): error TS1520: Expected a class set oprand.
regularExpressionScanning.ts(38,9): error TS1520: Expected a class set operand.
regularExpressionScanning.ts(38,11): error TS1520: Expected a class set operand.
regularExpressionScanning.ts(38,12): error TS1005: '--' expected.
regularExpressionScanning.ts(38,15): error TS1522: A character class must not contain a reserved double punctuator. Did you mean to escape it with backslash?
regularExpressionScanning.ts(38,20): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead.
@@ -173,15 +173,15 @@ regularExpressionScanning.ts(38,28): error TS1519: Operators must not be mixed w
regularExpressionScanning.ts(38,40): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead.
regularExpressionScanning.ts(38,47): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead.
regularExpressionScanning.ts(38,49): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead.
regularExpressionScanning.ts(38,50): error TS1520: Expected a class set oprand.
regularExpressionScanning.ts(38,50): error TS1520: Expected a class set operand.
regularExpressionScanning.ts(38,55): error TS1511: '\q' is only available inside character class.
regularExpressionScanning.ts(38,57): error TS1508: Unexpected '{'. Did you mean to escape it with backslash?
regularExpressionScanning.ts(38,61): error TS1508: Unexpected '}'. Did you mean to escape it with backslash?
regularExpressionScanning.ts(38,66): error TS1508: Unexpected '-'. Did you mean to escape it with backslash?
regularExpressionScanning.ts(38,67): error TS1005: '--' expected.
regularExpressionScanning.ts(38,70): error TS1520: Expected a class set oprand.
regularExpressionScanning.ts(38,70): error TS1520: Expected a class set operand.
regularExpressionScanning.ts(38,75): error TS1508: Unexpected '&'. Did you mean to escape it with backslash?
regularExpressionScanning.ts(38,85): error TS1520: Expected a class set oprand.
regularExpressionScanning.ts(38,85): error TS1520: Expected a class set operand.
regularExpressionScanning.ts(38,87): error TS1501: This regular expression flag is only available when targeting 'esnext' or later.
regularExpressionScanning.ts(39,56): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead.
regularExpressionScanning.ts(39,67): error TS1005: '&&' expected.
@@ -582,9 +582,9 @@ regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag
!!! error TS1005: '--' expected.
!!! error TS1520: Expected a class set oprand.
!!! error TS1520: Expected a class set operand.
!!! error TS1520: Expected a class set oprand.
!!! error TS1520: Expected a class set operand.
!!! error TS1005: '--' expected.
~~
@@ -600,7 +600,7 @@ regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag
~
!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead.
!!! error TS1520: Expected a class set oprand.
!!! error TS1520: Expected a class set operand.
~~
!!! error TS1511: '\q' is only available inside character class.
~
@@ -612,11 +612,11 @@ regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag
!!! error TS1005: '--' expected.
!!! error TS1520: Expected a class set oprand.
!!! error TS1520: Expected a class set operand.
~
!!! error TS1508: Unexpected '&'. Did you mean to escape it with backslash?
!!! error TS1520: Expected a class set oprand.
!!! error TS1520: Expected a class set operand.
~
!!! error TS1501: This regular expression flag is only available when targeting 'esnext' or later.
/[[^\P{Decimal_Number}&&[0-9]]&&\p{L}&&\p{ID_Continue}--\p{ASCII}\p{CWCF}]/v,
@@ -141,8 +141,8 @@ regularExpressionScanning.ts(37,61): error TS1508: Unexpected '}'. Did you mean
regularExpressionScanning.ts(37,63): error TS1517: Range out of order in character class.
regularExpressionScanning.ts(37,76): error TS1535: This character cannot be escaped in a regular expression.
regularExpressionScanning.ts(38,8): error TS1005: '--' expected.
regularExpressionScanning.ts(38,9): error TS1520: Expected a class set oprand.
regularExpressionScanning.ts(38,11): error TS1520: Expected a class set oprand.
regularExpressionScanning.ts(38,9): error TS1520: Expected a class set operand.
regularExpressionScanning.ts(38,11): error TS1520: Expected a class set operand.
regularExpressionScanning.ts(38,12): error TS1005: '--' expected.
regularExpressionScanning.ts(38,15): error TS1522: A character class must not contain a reserved double punctuator. Did you mean to escape it with backslash?
regularExpressionScanning.ts(38,20): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead.
@@ -150,15 +150,15 @@ regularExpressionScanning.ts(38,28): error TS1519: Operators must not be mixed w
regularExpressionScanning.ts(38,40): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead.
regularExpressionScanning.ts(38,47): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead.
regularExpressionScanning.ts(38,49): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead.
regularExpressionScanning.ts(38,50): error TS1520: Expected a class set oprand.
regularExpressionScanning.ts(38,50): error TS1520: Expected a class set operand.
regularExpressionScanning.ts(38,55): error TS1511: '\q' is only available inside character class.
regularExpressionScanning.ts(38,57): error TS1508: Unexpected '{'. Did you mean to escape it with backslash?
regularExpressionScanning.ts(38,61): error TS1508: Unexpected '}'. Did you mean to escape it with backslash?
regularExpressionScanning.ts(38,66): error TS1508: Unexpected '-'. Did you mean to escape it with backslash?
regularExpressionScanning.ts(38,67): error TS1005: '--' expected.
regularExpressionScanning.ts(38,70): error TS1520: Expected a class set oprand.
regularExpressionScanning.ts(38,70): error TS1520: Expected a class set operand.
regularExpressionScanning.ts(38,75): error TS1508: Unexpected '&'. Did you mean to escape it with backslash?
regularExpressionScanning.ts(38,85): error TS1520: Expected a class set oprand.
regularExpressionScanning.ts(38,85): error TS1520: Expected a class set operand.
regularExpressionScanning.ts(39,56): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead.
regularExpressionScanning.ts(39,67): error TS1005: '&&' expected.
regularExpressionScanning.ts(41,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class.
@@ -503,9 +503,9 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly
!!! error TS1005: '--' expected.
!!! error TS1520: Expected a class set oprand.
!!! error TS1520: Expected a class set operand.
!!! error TS1520: Expected a class set oprand.
!!! error TS1520: Expected a class set operand.
!!! error TS1005: '--' expected.
~~
@@ -521,7 +521,7 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly
~
!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead.
!!! error TS1520: Expected a class set oprand.
!!! error TS1520: Expected a class set operand.
~~
!!! error TS1511: '\q' is only available inside character class.
~
@@ -533,11 +533,11 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly
!!! error TS1005: '--' expected.
!!! error TS1520: Expected a class set oprand.
!!! error TS1520: Expected a class set operand.
~
!!! error TS1508: Unexpected '&'. Did you mean to escape it with backslash?
!!! error TS1520: Expected a class set oprand.
!!! error TS1520: Expected a class set operand.
/[[^\P{Decimal_Number}&&[0-9]]&&\p{L}&&\p{ID_Continue}--\p{ASCII}\p{CWCF}]/v,
~~
!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead.