From 8cd8c3c370b3527bee47f79e0ba93f7185357fd0 Mon Sep 17 00:00:00 2001 From: graphemecluster Date: Thu, 23 Jan 2025 03:19:13 +0800 Subject: [PATCH 1/4] Fix: Text in-between Unicode escapes are skipped in identifiers - Added the `scanIdentifierStart` method - Refactored `scanIdentifierParts` & `scanIdentifier` Implementing the above automatically fixes another issue that Unicode escapes & extended Unicode escapes are not recognised at the beginning of a RegExp group name. --- src/compiler/scanner.ts | 200 ++++-------- .../reference/TypeArgumentList1.errors.txt | 2 +- ...torWithIncompleteTypeAnnotation.errors.txt | 2 +- .../invalidUnicodeEscapeSequance.errors.txt | 2 +- .../invalidUnicodeEscapeSequance2.errors.txt | 2 +- .../invalidUnicodeEscapeSequance3.errors.txt | 2 +- .../invalidUnicodeEscapeSequance4.errors.txt | 2 +- ...manyCompilerErrorsInTheTwoFiles.errors.txt | 24 +- .../manyCompilerErrorsInTheTwoFiles.js | 5 +- .../manyCompilerErrorsInTheTwoFiles.types | 8 - .../reference/parserSkippedTokens1.errors.txt | 2 +- .../parserSkippedTokens10.errors.txt | 4 +- .../parserSkippedTokens11.errors.txt | 6 +- .../parserSkippedTokens12.errors.txt | 6 +- .../parserSkippedTokens13.errors.txt | 2 +- .../parserSkippedTokens14.errors.txt | 4 +- .../parserSkippedTokens15.errors.txt | 4 +- .../parserSkippedTokens17.errors.txt | 2 +- .../parserSkippedTokens18.errors.txt | 2 +- .../parserSkippedTokens19.errors.txt | 2 +- .../reference/parserSkippedTokens2.errors.txt | 4 +- .../parserSkippedTokens20.errors.txt | 2 +- .../reference/parserSkippedTokens3.errors.txt | 4 +- .../reference/parserSkippedTokens4.errors.txt | 2 +- .../reference/parserSkippedTokens5.errors.txt | 2 +- .../reference/parserSkippedTokens6.errors.txt | 2 +- .../reference/parserSkippedTokens7.errors.txt | 2 +- .../reference/parserSkippedTokens8.errors.txt | 2 +- .../reference/parserSkippedTokens9.errors.txt | 2 +- .../parserX_TypeArgumentList1.errors.txt | 2 +- .../reference/shebangError.errors.txt | 9 +- tests/baselines/reference/shebangError.js | 2 +- tests/baselines/reference/shebangError.types | 6 +- ...slashBeforeVariableDeclaration1.errors.txt | 2 +- ...EscapesInNames02(target=es2015).errors.txt | 4 +- ...odeEscapesInNames02(target=es5).errors.txt | 40 +-- .../unicodeEscapesInNames02(target=es5).js | 16 +- ...unicodeEscapesInNames02(target=es5).js.map | 4 +- ...EscapesInNames02(target=es5).sourcemap.txt | 292 ++++++------------ ...nicodeEscapesInNames02(target=es5).symbols | 4 - .../unicodeEscapesInNames02(target=es5).types | 34 +- 41 files changed, 241 insertions(+), 479 deletions(-) diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 50e827c17bd24..8223d5c56080e 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -976,8 +976,8 @@ export function isIdentifierStart(ch: number, languageVersion: ScriptTarget | un export function isIdentifierPart(ch: number, languageVersion: ScriptTarget | undefined, identifierVariant?: LanguageVariant): boolean { return isWordCharacter(ch) || ch === CharacterCodes.$ || - // "-" and ":" are valid in JSX Identifiers - (identifierVariant === LanguageVariant.JSX ? (ch === CharacterCodes.minus || ch === CharacterCodes.colon) : false) || + // "-" is valid in JSX Identifiers. ":" is part of JSXNamespacedName but not JSXIdentifier. + identifierVariant === LanguageVariant.JSX && ch === CharacterCodes.minus || ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierPart(ch, languageVersion); } @@ -1328,9 +1328,9 @@ export function createScanner( } const identifierStart = pos; - const { length } = scanIdentifierParts(); + const { length } = scanIdentifierParts(languageVersion); - if (length === 1 && text[identifierStart] === "n") { + if (length === 1 && codePointUnchecked(identifierStart) === CharacterCodes.n) { if (isScientific) { error(Diagnostics.A_bigint_literal_cannot_use_exponential_notation, numericStart, identifierStart - numericStart + 1); } @@ -1777,35 +1777,36 @@ export function createScanner( return -1; } - function scanIdentifierParts(): string { + function scanIdentifierParts(languageVersion: ScriptTarget, identifierVariant?: LanguageVariant): string { let result = ""; let start = pos; while (pos < end) { let ch = codePointUnchecked(pos); - if (isIdentifierPart(ch, languageVersion)) { + if (isIdentifierPart(ch, languageVersion, identifierVariant)) { pos += charSize(ch); + continue; } - else if (ch === CharacterCodes.backslash) { + + if (ch === CharacterCodes.backslash) { ch = peekExtendedUnicodeEscape(); - if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { + if (ch >= 0 && isIdentifierPart(ch, languageVersion, identifierVariant)) { + result += text.substring(start, pos); result += scanExtendedUnicodeEscape(/*shouldEmitInvalidEscapeError*/ true); start = pos; continue; } + ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { - break; + if (ch >= 0 && isIdentifierPart(ch, languageVersion, identifierVariant)) { + tokenFlags |= TokenFlags.UnicodeEscape; + result += text.substring(start, pos); + result += String.fromCharCode(ch); + pos += 6; // Valid Unicode escape is always six characters + start = pos; + continue; } - tokenFlags |= TokenFlags.UnicodeEscape; - result += text.substring(start, pos); - result += utf16EncodeAsString(ch); - // Valid Unicode escape is always six characters - pos += 6; - start = pos; - } - else { - break; } + break; } result += text.substring(start, pos); return result; @@ -2302,72 +2303,26 @@ export function createScanner( case CharacterCodes.at: pos++; return token = SyntaxKind.AtToken; - case CharacterCodes.backslash: - const extendedCookedChar = peekExtendedUnicodeEscape(); - if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { - tokenValue = scanExtendedUnicodeEscape(/*shouldEmitInvalidEscapeError*/ true) + scanIdentifierParts(); - return token = getIdentifierToken(); - } - - const cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { - pos += 6; - tokenFlags |= TokenFlags.UnicodeEscape; - tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); - return token = getIdentifierToken(); - } - - error(Diagnostics.Invalid_character); - pos++; - return token = SyntaxKind.Unknown; case CharacterCodes.hash: - if (pos !== 0 && text[pos + 1] === "!") { - error(Diagnostics.can_only_be_used_at_the_start_of_a_file, pos, 2); + pos++; + if (pos !== 1 && codePointUnchecked(pos) === CharacterCodes.exclamation) { pos++; + error(Diagnostics.can_only_be_used_at_the_start_of_a_file, pos - 2, 2); return token = SyntaxKind.Unknown; } - const charAfterHash = codePointUnchecked(pos + 1); - if (charAfterHash === CharacterCodes.backslash) { - pos++; - const extendedCookedChar = peekExtendedUnicodeEscape(); - if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { - tokenValue = "#" + scanExtendedUnicodeEscape(/*shouldEmitInvalidEscapeError*/ true) + scanIdentifierParts(); - return token = SyntaxKind.PrivateIdentifier; - } - - const cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { - pos += 6; - tokenFlags |= TokenFlags.UnicodeEscape; - tokenValue = "#" + String.fromCharCode(cookedChar) + scanIdentifierParts(); - return token = SyntaxKind.PrivateIdentifier; - } - pos--; - } - - if (isIdentifierStart(charAfterHash, languageVersion)) { - pos++; - // We're relying on scanIdentifier's behavior and adjusting the token kind after the fact. - // Notably absent from this block is the fact that calling a function named "scanIdentifier", - // but identifiers don't include '#', and that function doesn't deal with it at all. - // This works because 'scanIdentifier' tries to reuse source characters and builds up substrings; - // however, it starts at the 'tokenPos' which includes the '#', and will "accidentally" prepend the '#' for us. - scanIdentifier(charAfterHash, languageVersion); - } - else { - tokenValue = "#"; - error(Diagnostics.Invalid_character, pos++, charSize(ch)); + if (!scanIdentifier(languageVersion)) { + error(Diagnostics.Invalid_character, pos - 1, 1); } + tokenValue = "#" + tokenValue; return token = SyntaxKind.PrivateIdentifier; case CharacterCodes.replacementCharacter: error(Diagnostics.File_appears_to_be_binary, 0, 0); pos = end; return token = SyntaxKind.NonTextFileMarkerTrivia; default: - const identifierKind = scanIdentifier(ch, languageVersion); - if (identifierKind) { - return token = identifierKind; + if (scanIdentifier(languageVersion)) { + return token; } else if (isWhiteSpaceSingleLine(ch)) { pos += charSize(ch); @@ -2411,27 +2366,39 @@ export function createScanner( function reScanInvalidIdentifier(): SyntaxKind { Debug.assert(token === SyntaxKind.Unknown, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); pos = tokenStart = fullStartPos; - tokenFlags = 0; - const ch = codePointUnchecked(pos); - const identifierKind = scanIdentifier(ch, ScriptTarget.ESNext); - if (identifierKind) { - return token = identifierKind; - } - pos += charSize(ch); - return token; // Still `SyntaxKind.Unknown` + tokenFlags = TokenFlags.None; + return scanIdentifier(ScriptTarget.ESNext); } - function scanIdentifier(startCharacter: number, languageVersion: ScriptTarget) { - let ch = startCharacter; - if (isIdentifierStart(ch, languageVersion)) { - pos += charSize(ch); - while (pos < end && isIdentifierPart(ch = codePointUnchecked(pos), languageVersion)) pos += charSize(ch); - tokenValue = text.substring(tokenStart, pos); - if (ch === CharacterCodes.backslash) { - tokenValue += scanIdentifierParts(); + function scanIdentifierStart(languageVersion: ScriptTarget): string { + const ch = codePointChecked(pos); + if (ch === CharacterCodes.backslash) { + const extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + return scanExtendedUnicodeEscape(/*shouldEmitInvalidEscapeError*/ true); } - return getIdentifierToken(); + + const cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; // Valid Unicode escape is always six characters + tokenFlags |= TokenFlags.UnicodeEscape; + return String.fromCharCode(cookedChar); + } + } + else if (isIdentifierStart(ch, languageVersion)) { + pos += charSize(ch); + return utf16EncodeAsString(ch); } + return ""; + } + + function scanIdentifier(languageVersion: ScriptTarget, identifierVariant?: LanguageVariant) { + tokenValue = scanIdentifierStart(languageVersion); + if (tokenValue) { + tokenValue += scanIdentifierParts(languageVersion, identifierVariant); + return token = getIdentifierToken(); + } + return token = SyntaxKind.Unknown; } function reScanGreaterToken(): SyntaxKind { @@ -2996,8 +2963,7 @@ export function createScanner( function scanGroupName(isReference: boolean) { Debug.assertEqual(charCodeUnchecked(pos - 1), CharacterCodes.lessThan); tokenStart = pos; - scanIdentifier(codePointChecked(pos), languageVersion); - if (pos === tokenStart) { + if (!scanIdentifier(languageVersion)) { error(Diagnostics.Expected_a_capturing_group_name); } else if (isReference) { @@ -3772,19 +3738,8 @@ export function createScanner( // everything after it to the token // Do note that this means that `scanJsxIdentifier` effectively _mutates_ the visible token without advancing to a new token // Any caller should be expecting this behavior and should only read the pos or token value after calling it. - while (pos < end) { - const ch = charCodeUnchecked(pos); - if (ch === CharacterCodes.minus) { - tokenValue += "-"; - pos++; - continue; - } - const oldPos = pos; - tokenValue += scanIdentifierParts(); // reuse `scanIdentifierParts` so unicode escapes are handled - if (pos === oldPos) { - break; - } - } + // Here `scanIdentifierParts` is reused to ensure unicode escapes are handled. + tokenValue += scanIdentifierParts(languageVersion, LanguageVariant.JSX); return getIdentifierToken(); } return token; @@ -3893,36 +3848,11 @@ export function createScanner( return token = SyntaxKind.BacktickToken; case CharacterCodes.hash: return token = SyntaxKind.HashToken; - case CharacterCodes.backslash: - pos--; - const extendedCookedChar = peekExtendedUnicodeEscape(); - if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { - tokenValue = scanExtendedUnicodeEscape(/*shouldEmitInvalidEscapeError*/ true) + scanIdentifierParts(); - return token = getIdentifierToken(); - } - - const cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { - pos += 6; - tokenFlags |= TokenFlags.UnicodeEscape; - tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); - return token = getIdentifierToken(); - } - pos++; - return token = SyntaxKind.Unknown; - } - - if (isIdentifierStart(ch, languageVersion)) { - let char = ch; - while (pos < end && isIdentifierPart(char = codePointUnchecked(pos), languageVersion) || char === CharacterCodes.minus) pos += charSize(char); - tokenValue = text.substring(tokenStart, pos); - if (char === CharacterCodes.backslash) { - tokenValue += scanIdentifierParts(); - } - return token = getIdentifierToken(); - } - else { - return token = SyntaxKind.Unknown; + default: + pos = tokenStart; + const identifierKind = scanIdentifier(languageVersion, LanguageVariant.JSX); + if (!identifierKind) pos += charSize(ch); // skip the character + return identifierKind; } } diff --git a/tests/baselines/reference/TypeArgumentList1.errors.txt b/tests/baselines/reference/TypeArgumentList1.errors.txt index 58d2cab35499e..243e273081a67 100644 --- a/tests/baselines/reference/TypeArgumentList1.errors.txt +++ b/tests/baselines/reference/TypeArgumentList1.errors.txt @@ -21,7 +21,7 @@ TypeArgumentList1.ts(1,14): error TS2695: Left side of comma operator is unused !!! error TS2304: Cannot find name 'A'. ~ !!! error TS2304: Cannot find name 'B'. - + ~ !!! error TS1127: Invalid character. ~ !!! error TS2304: Cannot find name 'C'. diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt index fcdb9edc337d7..e0d7895751057 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt @@ -221,7 +221,7 @@ constructorWithIncompleteTypeAnnotation.ts(261,1): error TS1128: Declaration or var undef = undefined; var _\uD4A5\u7204\uC316\uE59F = local; - + ~ !!! error TS1127: Invalid character. var ΠΌΠΈΡ€ = local; diff --git a/tests/baselines/reference/invalidUnicodeEscapeSequance.errors.txt b/tests/baselines/reference/invalidUnicodeEscapeSequance.errors.txt index 0155ab8136ad4..8c48ef350c004 100644 --- a/tests/baselines/reference/invalidUnicodeEscapeSequance.errors.txt +++ b/tests/baselines/reference/invalidUnicodeEscapeSequance.errors.txt @@ -3,5 +3,5 @@ invalidUnicodeEscapeSequance.ts(1,8): error TS1127: Invalid character. ==== invalidUnicodeEscapeSequance.ts (1 errors) ==== var arg\u003 - + ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tests/baselines/reference/invalidUnicodeEscapeSequance2.errors.txt b/tests/baselines/reference/invalidUnicodeEscapeSequance2.errors.txt index be53351d2556d..a80b68cec8229 100644 --- a/tests/baselines/reference/invalidUnicodeEscapeSequance2.errors.txt +++ b/tests/baselines/reference/invalidUnicodeEscapeSequance2.errors.txt @@ -3,5 +3,5 @@ invalidUnicodeEscapeSequance2.ts(1,8): error TS1127: Invalid character. ==== invalidUnicodeEscapeSequance2.ts (1 errors) ==== var arg\uxxxx - + ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tests/baselines/reference/invalidUnicodeEscapeSequance3.errors.txt b/tests/baselines/reference/invalidUnicodeEscapeSequance3.errors.txt index a10942f2d9abf..a664586e11850 100644 --- a/tests/baselines/reference/invalidUnicodeEscapeSequance3.errors.txt +++ b/tests/baselines/reference/invalidUnicodeEscapeSequance3.errors.txt @@ -7,7 +7,7 @@ invalidUnicodeEscapeSequance3.ts(1,3): error TS2304: Cannot find name 'u'. a\u ~ !!! error TS2304: Cannot find name 'a'. - + ~ !!! error TS1127: Invalid character. ~ !!! error TS2304: Cannot find name 'u'. \ No newline at end of file diff --git a/tests/baselines/reference/invalidUnicodeEscapeSequance4.errors.txt b/tests/baselines/reference/invalidUnicodeEscapeSequance4.errors.txt index df0d9a0f4a8f5..90cdaf6fbda67 100644 --- a/tests/baselines/reference/invalidUnicodeEscapeSequance4.errors.txt +++ b/tests/baselines/reference/invalidUnicodeEscapeSequance4.errors.txt @@ -4,5 +4,5 @@ invalidUnicodeEscapeSequance4.ts(2,5): error TS1127: Invalid character. ==== invalidUnicodeEscapeSequance4.ts (1 errors) ==== var a\u0031; // a1 is a valid identifier var \u0031a; // 1a is an invalid identifier - + ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tests/baselines/reference/manyCompilerErrorsInTheTwoFiles.errors.txt b/tests/baselines/reference/manyCompilerErrorsInTheTwoFiles.errors.txt index 97edb82b46bb6..f8577aced4c70 100644 --- a/tests/baselines/reference/manyCompilerErrorsInTheTwoFiles.errors.txt +++ b/tests/baselines/reference/manyCompilerErrorsInTheTwoFiles.errors.txt @@ -2,22 +2,18 @@ 1 const a =!@#!@$    ~~ -a.ts:1:13 - error TS1134: Variable declaration expected. +a.ts:1:14 - error TS1134: Variable declaration expected. 1 const a =!@#!@$ -   ~ -a.ts:1:16 - error TS1109: Expression expected. - -1 const a =!@#!@$ -    +   ~ a.ts:2:13 - error TS18026: '#!' can only be used at the start of a file. 2 const b = !@#!@#!@#!    ~~ -a.ts:2:14 - error TS1134: Variable declaration expected. +a.ts:2:15 - error TS1134: Variable declaration expected. 2 const b = !@#!@#!@#! -   ~ +   ~ a.ts:2:16 - error TS18026: '#!' can only be used at the start of a file. 2 const b = !@#!@#!@#! @@ -76,18 +72,16 @@   ~~~~~ -==== a.ts (16 errors) ==== +==== a.ts (15 errors) ==== const a =!@#!@$ ~~ !!! error TS18026: '#!' can only be used at the start of a file. - ~ + ~ !!! error TS1134: Variable declaration expected. - -!!! error TS1109: Expression expected. const b = !@#!@#!@#! ~~ !!! error TS18026: '#!' can only be used at the start of a file. - ~ + ~ !!! error TS1134: Variable declaration expected. ~~ !!! error TS18026: '#!' can only be used at the start of a file. @@ -125,8 +119,8 @@ limit ~~~~~ !!! error TS2304: Cannot find name 'limit'. -Found 19 errors in 2 files. +Found 18 errors in 2 files. Errors Files - 16 a.ts:1 + 15 a.ts:1 3 b.ts:1 diff --git a/tests/baselines/reference/manyCompilerErrorsInTheTwoFiles.js b/tests/baselines/reference/manyCompilerErrorsInTheTwoFiles.js index 4953a653c3da7..91d5a2de7ab3a 100644 --- a/tests/baselines/reference/manyCompilerErrorsInTheTwoFiles.js +++ b/tests/baselines/reference/manyCompilerErrorsInTheTwoFiles.js @@ -14,11 +14,8 @@ limit //// [a.js] var a = !; -!; var b = !; -!; -!; -!OK; +OK; HERE; 's A shouty thing; GOTTA; diff --git a/tests/baselines/reference/manyCompilerErrorsInTheTwoFiles.types b/tests/baselines/reference/manyCompilerErrorsInTheTwoFiles.types index b52e6ebb02bd1..743c4d116ebf3 100644 --- a/tests/baselines/reference/manyCompilerErrorsInTheTwoFiles.types +++ b/tests/baselines/reference/manyCompilerErrorsInTheTwoFiles.types @@ -8,8 +8,6 @@ const a =!@#!@$ > : ^^^^^^^ > : any > : ^^^ ->!@$ : boolean -> : ^^^^^^^ >$ : any > : ^^^ @@ -20,16 +18,10 @@ const b = !@#!@#!@#! > : ^^^^^^^ > : any > : ^^^ ->!@ : boolean -> : ^^^^^^^ > : any > : ^^^ ->!@ : boolean -> : ^^^^^^^ > : any > : ^^^ ->!OK! : boolean -> : ^^^^^^^ OK! >OK! : any diff --git a/tests/baselines/reference/parserSkippedTokens1.errors.txt b/tests/baselines/reference/parserSkippedTokens1.errors.txt index ad127ed6202fc..501ce5e9e3b6d 100644 --- a/tests/baselines/reference/parserSkippedTokens1.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens1.errors.txt @@ -3,5 +3,5 @@ parserSkippedTokens1.ts(1,1): error TS1127: Invalid character. ==== parserSkippedTokens1.ts (1 errors) ==== \ - + ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tests/baselines/reference/parserSkippedTokens10.errors.txt b/tests/baselines/reference/parserSkippedTokens10.errors.txt index 516dd5df7af10..0d8b30a4d8d5d 100644 --- a/tests/baselines/reference/parserSkippedTokens10.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens10.errors.txt @@ -4,10 +4,10 @@ parserSkippedTokens10.ts(2,1): error TS1127: Invalid character. ==== parserSkippedTokens10.ts (2 errors) ==== \ - + ~ !!! error TS1127: Invalid character. \ - + ~ !!! error TS1127: Invalid character. /*existing trivia*/ ; \ No newline at end of file diff --git a/tests/baselines/reference/parserSkippedTokens11.errors.txt b/tests/baselines/reference/parserSkippedTokens11.errors.txt index cd6ae69a403a8..e77b428ed4a3f 100644 --- a/tests/baselines/reference/parserSkippedTokens11.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens11.errors.txt @@ -5,9 +5,9 @@ parserSkippedTokens11.ts(1,7): error TS1127: Invalid character. ==== parserSkippedTokens11.ts (3 errors) ==== ; \ \ \ - + ~ !!! error TS1127: Invalid character. - + ~ !!! error TS1127: Invalid character. - + ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tests/baselines/reference/parserSkippedTokens12.errors.txt b/tests/baselines/reference/parserSkippedTokens12.errors.txt index 45c96c0cd46e9..6cc9045ba02ce 100644 --- a/tests/baselines/reference/parserSkippedTokens12.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens12.errors.txt @@ -5,9 +5,9 @@ parserSkippedTokens12.ts(1,5): error TS1127: Invalid character. ==== parserSkippedTokens12.ts (3 errors) ==== \ \ \ - + ~ !!! error TS1127: Invalid character. - + ~ !!! error TS1127: Invalid character. - + ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tests/baselines/reference/parserSkippedTokens13.errors.txt b/tests/baselines/reference/parserSkippedTokens13.errors.txt index 23ee4b929e8df..9ff76d72b0fb0 100644 --- a/tests/baselines/reference/parserSkippedTokens13.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens13.errors.txt @@ -3,5 +3,5 @@ parserSkippedTokens13.ts(1,10): error TS1127: Invalid character. ==== parserSkippedTokens13.ts (1 errors) ==== /regexp/ \ ; - + ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tests/baselines/reference/parserSkippedTokens14.errors.txt b/tests/baselines/reference/parserSkippedTokens14.errors.txt index 8bda59449d8d1..0596e72fecd65 100644 --- a/tests/baselines/reference/parserSkippedTokens14.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens14.errors.txt @@ -4,11 +4,11 @@ parserSkippedTokens14.ts(3,1): error TS1127: Invalid character. ==== parserSkippedTokens14.ts (2 errors) ==== \ - + ~ !!! error TS1127: Invalid character. /*existing trivia*/ \ - + ~ !!! error TS1127: Invalid character. ; \ No newline at end of file diff --git a/tests/baselines/reference/parserSkippedTokens15.errors.txt b/tests/baselines/reference/parserSkippedTokens15.errors.txt index 80315a8f4d610..81baca94d19ad 100644 --- a/tests/baselines/reference/parserSkippedTokens15.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens15.errors.txt @@ -5,9 +5,9 @@ parserSkippedTokens15.ts(3,1): error TS1127: Invalid character. ==== parserSkippedTokens15.ts (2 errors) ==== /*existing trivia*/ \ - + ~ !!! error TS1127: Invalid character. \ - + ~ !!! error TS1127: Invalid character. ; \ No newline at end of file diff --git a/tests/baselines/reference/parserSkippedTokens17.errors.txt b/tests/baselines/reference/parserSkippedTokens17.errors.txt index caf45ae02d509..550a294f7d863 100644 --- a/tests/baselines/reference/parserSkippedTokens17.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens17.errors.txt @@ -10,7 +10,7 @@ parserSkippedTokens17.ts(1,9): error TS1005: ')' expected. !!! error TS2304: Cannot find name 'foo'. ~ !!! error TS2304: Cannot find name 'a'. - + ~ !!! error TS1127: Invalid character. !!! error TS1005: ')' expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserSkippedTokens18.errors.txt b/tests/baselines/reference/parserSkippedTokens18.errors.txt index 7930e0b851933..69a7d4d619f11 100644 --- a/tests/baselines/reference/parserSkippedTokens18.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens18.errors.txt @@ -10,7 +10,7 @@ parserSkippedTokens18.ts(1,8): error TS1005: ')' expected. !!! error TS2304: Cannot find name 'foo'. ~ !!! error TS2304: Cannot find name 'a'. - + ~ !!! error TS1127: Invalid character. !!! error TS1005: ')' expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserSkippedTokens19.errors.txt b/tests/baselines/reference/parserSkippedTokens19.errors.txt index 67037a5515f0c..cdad093c2569f 100644 --- a/tests/baselines/reference/parserSkippedTokens19.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens19.errors.txt @@ -3,5 +3,5 @@ parserSkippedTokens19.ts(1,1): error TS1127: Invalid character. ==== parserSkippedTokens19.ts (1 errors) ==== \ declare var v; - + ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tests/baselines/reference/parserSkippedTokens2.errors.txt b/tests/baselines/reference/parserSkippedTokens2.errors.txt index 45b873db89bea..f4f90e33d9b92 100644 --- a/tests/baselines/reference/parserSkippedTokens2.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens2.errors.txt @@ -4,7 +4,7 @@ parserSkippedTokens2.ts(1,2): error TS1127: Invalid character. ==== parserSkippedTokens2.ts (2 errors) ==== \\ - + ~ !!! error TS1127: Invalid character. - + ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tests/baselines/reference/parserSkippedTokens20.errors.txt b/tests/baselines/reference/parserSkippedTokens20.errors.txt index 7ea41ba3521f8..d6180f358217a 100644 --- a/tests/baselines/reference/parserSkippedTokens20.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens20.errors.txt @@ -9,5 +9,5 @@ parserSkippedTokens20.ts(1,12): error TS1127: Invalid character. !!! error TS2304: Cannot find name 'X'. ~ !!! error TS2304: Cannot find name 'T'. - + ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tests/baselines/reference/parserSkippedTokens3.errors.txt b/tests/baselines/reference/parserSkippedTokens3.errors.txt index a541f519ec0d9..27e8eb1829101 100644 --- a/tests/baselines/reference/parserSkippedTokens3.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens3.errors.txt @@ -4,7 +4,7 @@ parserSkippedTokens3.ts(1,5): error TS1127: Invalid character. ==== parserSkippedTokens3.ts (2 errors) ==== \ ; \ - + ~ !!! error TS1127: Invalid character. - + ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tests/baselines/reference/parserSkippedTokens4.errors.txt b/tests/baselines/reference/parserSkippedTokens4.errors.txt index 377f3b1f988d2..014346f6bac23 100644 --- a/tests/baselines/reference/parserSkippedTokens4.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens4.errors.txt @@ -3,5 +3,5 @@ parserSkippedTokens4.ts(1,1): error TS1127: Invalid character. ==== parserSkippedTokens4.ts (1 errors) ==== \ /regexp/; - + ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tests/baselines/reference/parserSkippedTokens5.errors.txt b/tests/baselines/reference/parserSkippedTokens5.errors.txt index 89709ef580ab0..f9ffe0a3daf13 100644 --- a/tests/baselines/reference/parserSkippedTokens5.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens5.errors.txt @@ -3,5 +3,5 @@ parserSkippedTokens5.ts(1,1): error TS1127: Invalid character. ==== parserSkippedTokens5.ts (1 errors) ==== \ /*foo*/ ; - + ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tests/baselines/reference/parserSkippedTokens6.errors.txt b/tests/baselines/reference/parserSkippedTokens6.errors.txt index b412af2f1baa6..8541b696670c4 100644 --- a/tests/baselines/reference/parserSkippedTokens6.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens6.errors.txt @@ -3,5 +3,5 @@ parserSkippedTokens6.ts(1,9): error TS1127: Invalid character. ==== parserSkippedTokens6.ts (1 errors) ==== /*foo*/ \ - + ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tests/baselines/reference/parserSkippedTokens7.errors.txt b/tests/baselines/reference/parserSkippedTokens7.errors.txt index a76c8b92cab7b..288b585785410 100644 --- a/tests/baselines/reference/parserSkippedTokens7.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens7.errors.txt @@ -3,5 +3,5 @@ parserSkippedTokens7.ts(1,9): error TS1127: Invalid character. ==== parserSkippedTokens7.ts (1 errors) ==== /*foo*/ \ /*bar*/ - + ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tests/baselines/reference/parserSkippedTokens8.errors.txt b/tests/baselines/reference/parserSkippedTokens8.errors.txt index 599792d38a6e4..6701f5a0ee42b 100644 --- a/tests/baselines/reference/parserSkippedTokens8.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens8.errors.txt @@ -4,5 +4,5 @@ parserSkippedTokens8.ts(2,9): error TS1127: Invalid character. ==== parserSkippedTokens8.ts (1 errors) ==== ; /*foo*/ \ /*bar*/ - + ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tests/baselines/reference/parserSkippedTokens9.errors.txt b/tests/baselines/reference/parserSkippedTokens9.errors.txt index 5187666e50b79..9e0284e5c6bce 100644 --- a/tests/baselines/reference/parserSkippedTokens9.errors.txt +++ b/tests/baselines/reference/parserSkippedTokens9.errors.txt @@ -4,5 +4,5 @@ parserSkippedTokens9.ts(2,9): error TS1127: Invalid character. ==== parserSkippedTokens9.ts (1 errors) ==== ; // existing trivia /*foo*/ \ /*bar*/ - + ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tests/baselines/reference/parserX_TypeArgumentList1.errors.txt b/tests/baselines/reference/parserX_TypeArgumentList1.errors.txt index cb9841a599111..d0d37030ef579 100644 --- a/tests/baselines/reference/parserX_TypeArgumentList1.errors.txt +++ b/tests/baselines/reference/parserX_TypeArgumentList1.errors.txt @@ -21,7 +21,7 @@ parserX_TypeArgumentList1.ts(1,14): error TS2695: Left side of comma operator is !!! error TS2304: Cannot find name 'A'. ~ !!! error TS2304: Cannot find name 'B'. - + ~ !!! error TS1127: Invalid character. ~ !!! error TS2304: Cannot find name 'C'. diff --git a/tests/baselines/reference/shebangError.errors.txt b/tests/baselines/reference/shebangError.errors.txt index 63d8730735c6a..392d4443fb887 100644 --- a/tests/baselines/reference/shebangError.errors.txt +++ b/tests/baselines/reference/shebangError.errors.txt @@ -1,20 +1,17 @@ shebangError.ts(2,1): error TS18026: '#!' can only be used at the start of a file. -shebangError.ts(2,2): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. -shebangError.ts(2,3): error TS2872: This kind of expression is always truthy. +shebangError.ts(2,3): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. shebangError.ts(2,12): error TS2304: Cannot find name 'env'. shebangError.ts(2,16): error TS1005: ';' expected. shebangError.ts(2,16): error TS2304: Cannot find name 'node'. -==== shebangError.ts (6 errors) ==== +==== shebangError.ts (5 errors) ==== var foo = 'Shebang is only allowed on the first line'; #!/usr/bin/env node ~~ !!! error TS18026: '#!' can only be used at the start of a file. - ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. ~~~~~~~~ -!!! error TS2872: This kind of expression is always truthy. +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. ~~~ !!! error TS2304: Cannot find name 'env'. ~~~~ diff --git a/tests/baselines/reference/shebangError.js b/tests/baselines/reference/shebangError.js index 95004e323f32c..77ea9a5c0d253 100644 --- a/tests/baselines/reference/shebangError.js +++ b/tests/baselines/reference/shebangError.js @@ -6,5 +6,5 @@ var foo = 'Shebang is only allowed on the first line'; //// [shebangError.js] var foo = 'Shebang is only allowed on the first line'; -!/usr/bin / env; +/usr/bin / env; node; diff --git a/tests/baselines/reference/shebangError.types b/tests/baselines/reference/shebangError.types index 40a7de47cdbb5..4e54b50f7369e 100644 --- a/tests/baselines/reference/shebangError.types +++ b/tests/baselines/reference/shebangError.types @@ -8,10 +8,8 @@ var foo = 'Shebang is only allowed on the first line'; > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #!/usr/bin/env node ->!/usr/bin/env : number -> : ^^^^^^ ->!/usr/bin : boolean -> : ^^^^^^^ +>/usr/bin/env : number +> : ^^^^^^ >/usr/bin : RegExp > : ^^^^^^ >env : any diff --git a/tests/baselines/reference/slashBeforeVariableDeclaration1.errors.txt b/tests/baselines/reference/slashBeforeVariableDeclaration1.errors.txt index 21a1c86ab4b56..39f04e4ddf134 100644 --- a/tests/baselines/reference/slashBeforeVariableDeclaration1.errors.txt +++ b/tests/baselines/reference/slashBeforeVariableDeclaration1.errors.txt @@ -3,5 +3,5 @@ slashBeforeVariableDeclaration1.ts(1,1): error TS1127: Invalid character. ==== slashBeforeVariableDeclaration1.ts (1 errors) ==== \ declare var v; - + ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tests/baselines/reference/unicodeEscapesInNames02(target=es2015).errors.txt b/tests/baselines/reference/unicodeEscapesInNames02(target=es2015).errors.txt index de53e2b1953e1..dc05e3caa10cb 100644 --- a/tests/baselines/reference/unicodeEscapesInNames02(target=es2015).errors.txt +++ b/tests/baselines/reference/unicodeEscapesInNames02(target=es2015).errors.txt @@ -32,11 +32,11 @@ astralAsSurrogatePair.ts(1,24): error TS2305: Module '"./extendedEscapesForAstra ==== astralAsSurrogatePair.ts (4 errors) ==== import { _𐊧 as \uD800\uDEA7 } from "./extendedEscapesForAstralsInVarsAndClasses.js"; - + ~ !!! error TS1127: Invalid character. ~~~~~ !!! error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'uD800'. - + ~ !!! error TS1127: Invalid character. ~~~~~ !!! error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'uDEA7'. diff --git a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).errors.txt b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).errors.txt index d0482948aa891..06610affedfc6 100644 --- a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).errors.txt +++ b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).errors.txt @@ -1,4 +1,4 @@ -error TS-1: Pre-emit (44) and post-emit (45) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! +error TS-1: Pre-emit (40) and post-emit (41) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! astralAsSurrogatePair.ts(1,11): error TS1127: Invalid character. astralAsSurrogatePair.ts(1,14): error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'as'. astralAsSurrogatePair.ts(1,17): error TS1127: Invalid character. @@ -25,9 +25,6 @@ extendedEscapesForAstralsInVarsAndClasses.ts(14,5): error TS2304: Cannot find na extendedEscapesForAstralsInVarsAndClasses.ts(14,19): error TS1005: ';' expected. extendedEscapesForAstralsInVarsAndClasses.ts(15,9): error TS2532: Object is possibly 'undefined'. extendedEscapesForAstralsInVarsAndClasses.ts(15,14): error TS1127: Invalid character. -extendedEscapesForAstralsInVarsAndClasses.ts(15,15): error TS1434: Unexpected keyword or identifier. -extendedEscapesForAstralsInVarsAndClasses.ts(15,20): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. -extendedEscapesForAstralsInVarsAndClasses.ts(15,24): error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the whole assignment in parentheses. extendedEscapesForAstralsInVarsAndClasses.ts(17,5): error TS2304: Cannot find name 'methodA'. extendedEscapesForAstralsInVarsAndClasses.ts(17,15): error TS1005: ';' expected. extendedEscapesForAstralsInVarsAndClasses.ts(18,21): error TS1127: Invalid character. @@ -36,8 +33,7 @@ extendedEscapesForAstralsInVarsAndClasses.ts(22,13): error TS1127: Invalid chara extendedEscapesForAstralsInVarsAndClasses.ts(22,16): error TS1134: Variable declaration expected. extendedEscapesForAstralsInVarsAndClasses.ts(22,18): error TS1389: 'new' is not allowed as a variable declaration name. extendedEscapesForAstralsInVarsAndClasses.ts(22,28): error TS1127: Invalid character. -extendedEscapesForAstralsInVarsAndClasses.ts(22,29): error TS1434: Unexpected keyword or identifier. -extendedEscapesForAstralsInVarsAndClasses.ts(22,34): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. +extendedEscapesForAstralsInVarsAndClasses.ts(22,28): error TS2339: Property '\u{102A7}' does not exist on type 'Foo'. extendedEscapesForAstralsInVarsAndClasses.ts(22,50): error TS2339: Property 'methodA' does not exist on type 'Foo'. extendedEscapesForAstralsInVarsAndClasses.ts(24,2): error TS1127: Invalid character. extendedEscapesForAstralsInVarsAndClasses.ts(24,3): error TS1434: Unexpected keyword or identifier. @@ -45,10 +41,10 @@ extendedEscapesForAstralsInVarsAndClasses.ts(24,8): error TS1351: An identifier extendedEscapesForAstralsInVarsAndClasses.ts(24,12): error TS1128: Declaration or statement expected. -!!! error TS-1: Pre-emit (44) and post-emit (45) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! +!!! error TS-1: Pre-emit (40) and post-emit (41) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! !!! related TS-1: The excess diagnostics are: !!! related TS2532 extendedEscapesForAstralsInVarsAndClasses.ts:18:16: Object is possibly 'undefined'. -==== extendedEscapesForAstralsInVarsAndClasses.ts (38 errors) ==== +==== extendedEscapesForAstralsInVarsAndClasses.ts (34 errors) ==== // U+102A7 CARIAN LETTER A2 var 𐊧: string; ~~ @@ -56,7 +52,7 @@ extendedEscapesForAstralsInVarsAndClasses.ts(24,12): error TS1128: Declaration o ~ !!! error TS1134: Variable declaration expected. var \u{102A7}: string; - + ~ !!! error TS1127: Invalid character. ~ !!! error TS1005: ',' expected. @@ -72,7 +68,7 @@ extendedEscapesForAstralsInVarsAndClasses.ts(24,12): error TS1128: Declaration o } else { \u{102A7} = "hallo"; - + ~ !!! error TS1127: Invalid character. ~ !!! error TS1434: Unexpected keyword or identifier. @@ -84,7 +80,7 @@ extendedEscapesForAstralsInVarsAndClasses.ts(24,12): error TS1128: Declaration o class Foo { \u{102A7}: string; - + ~ !!! error TS1127: Invalid character. ~ !!! error TS1434: Unexpected keyword or identifier. @@ -102,14 +98,8 @@ extendedEscapesForAstralsInVarsAndClasses.ts(24,12): error TS1128: Declaration o this.\u{102A7} = " world"; ~~~~ !!! error TS2532: Object is possibly 'undefined'. - + ~ !!! error TS1127: Invalid character. - ~ -!!! error TS1434: Unexpected keyword or identifier. - ~~ -!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. - ~ -!!! error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the whole assignment in parentheses. } methodA() { ~~~~~~~ @@ -131,17 +121,15 @@ extendedEscapesForAstralsInVarsAndClasses.ts(24,12): error TS1128: Declaration o !!! error TS1134: Variable declaration expected. ~~~ !!! error TS1389: 'new' is not allowed as a variable declaration name. - + ~ !!! error TS1127: Invalid character. - ~ -!!! error TS1434: Unexpected keyword or identifier. - ~~ -!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. + ~~~~~~~~~ +!!! error TS2339: Property '\u{102A7}' does not exist on type 'Foo'. ~~~~~~~ !!! error TS2339: Property 'methodA' does not exist on type 'Foo'. _\u{102A7} += "!"; - + ~ !!! error TS1127: Invalid character. ~ !!! error TS1434: Unexpected keyword or identifier. @@ -156,11 +144,11 @@ extendedEscapesForAstralsInVarsAndClasses.ts(24,12): error TS1128: Declaration o !!! error TS1127: Invalid character. ~~ !!! error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'as'. - + ~ !!! error TS1127: Invalid character. ~~~~~ !!! error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'uD800'. - + ~ !!! error TS1127: Invalid character. ~~~~~ !!! error TS2305: Module '"./extendedEscapesForAstralsInVarsAndClasses.js"' has no exported member 'uDEA7'. diff --git a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).js b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).js index 2d6548b846408..f5b2c3992cbfb 100644 --- a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).js +++ b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).js @@ -57,26 +57,14 @@ var Foo = /** @class */ (function () { string; constructor(); { - this.; - u; - { - 102; - A7; - } - " world"; + this.𐊧 = " world"; } methodA(); { return this.𐊧; } export var _; -new Foo().; -u; -{ - 102; - A7; -} -+new Foo().methodA(); +new Foo().𐊧 + new Foo().methodA(); _; u; { diff --git a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).js.map b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).js.map index e62265291f04f..d721efc3125f1 100644 --- a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).js.map +++ b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).js.map @@ -1,6 +1,6 @@ //// [extendedEscapesForAstralsInVarsAndClasses.js.map] -{"version":3,"file":"extendedEscapesForAstralsInVarsAndClasses.js","sourceRoot":"","sources":["extendedEscapesForAstralsInVarsAndClasses.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,IAAQ,MAAM,CAAC;AACV,IAAA,CAAC,EAAI,EAAE,gBAAA,CAAU;AAEtB,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;IACX,OAAO,CAAC;AACjB,CAAC;KACI,CAAC;IACD,CAAC,CAAA;IAAA,CAAC;QAAA,GAAG,CAAA;QAAA,EAAE,CAAA;IAAA,CAAC;IAAG,OAAO,CAAC;AACxB,CAAC;AAED;IAAA;IACM,CAAC,AAAD;IAAA,UAAC;AAAD,CAAC,AAAD,AADN,IACM;AAAA,CAAC;IAAA,GAAG,CAAA;IAAA,EAAE,CAAA;AAAA,CAAC;AAAE,MAAM,CAAC;AAClB,WAAW,EAAE,CAAA;AAAC,CAAC;IACX,IAAI,CAAC,CAAA;IAAC,CAAC,CAAA;IAAA,CAAC;QAAA,GAAG,CAAA;QAAA,EAAE,CAAA;IAAA,CAAC;IAAG,QAAQ,CAAC;AAC9B,CAAC;AACD,OAAO,EAAE,CAAA;AAAC,CAAC;IACP,OAAO,IAAI,CAAC,EAAE,CAAC;AACnB,CAAC;AAGL,MAAM,CAAC,IAAI,CAAK,CAAA;AAAC,IAAI,GAAG,EAAE,CAAC,CAAA;AAAC,CAAC,CAAA;AAAA,CAAC;IAAA,GAAG,CAAA;IAAA,EAAE,CAAA;AAAA,CAAC;AAAC,CAAE,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;AAE3D,CAAC,CAAA;AAAC,CAAC,CAAA;AAAA,CAAC;IAAA,GAAG,CAAA;IAAA,EAAE,CAAA;AAAA,CAAC;AAAI,GAAG,CAAC"} -//// https://sokra.github.io/source-map-visualization#base64,Ly8gVSsxMDJBNyBDQVJJQU4gTEVUVEVSIEEyDQp2YXIgc3RyaW5nOw0KdmFyIHUsIEE3ID0gKHZvaWQgMClbMTAyXTsNCmlmIChNYXRoLnJhbmRvbSgpKSB7DQogICAgImhlbGxvIjsNCn0NCmVsc2Ugew0KICAgIHU7DQogICAgew0KICAgICAgICAxMDI7DQogICAgICAgIEE3Ow0KICAgIH0NCiAgICAiaGFsbG8iOw0KfQ0KdmFyIEZvbyA9IC8qKiBAY2xhc3MgKi8gKGZ1bmN0aW9uICgpIHsNCiAgICBmdW5jdGlvbiBGb28oKSB7DQogICAgfQ0KICAgIHJldHVybiBGb287DQp9KCkpOw0Kew0KICAgIDEwMjsNCiAgICBBNzsNCn0NCnN0cmluZzsNCmNvbnN0cnVjdG9yKCk7DQp7DQogICAgdGhpcy47DQogICAgdTsNCiAgICB7DQogICAgICAgIDEwMjsNCiAgICAgICAgQTc7DQogICAgfQ0KICAgICIgd29ybGQiOw0KfQ0KbWV0aG9kQSgpOw0Kew0KICAgIHJldHVybiB0aGlzLu2ggO26pzsNCn0NCmV4cG9ydCB2YXIgXzsNCm5ldyBGb28oKS47DQp1Ow0Kew0KICAgIDEwMjsNCiAgICBBNzsNCn0NCituZXcgRm9vKCkubWV0aG9kQSgpOw0KXzsNCnU7DQp7DQogICAgMTAyOw0KICAgIEE3Ow0KfQ0KIiEiOw0KLy8jIHNvdXJjZU1hcHBpbmdVUkw9ZXh0ZW5kZWRFc2NhcGVzRm9yQXN0cmFsc0luVmFyc0FuZENsYXNzZXMuanMubWFw,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXh0ZW5kZWRFc2NhcGVzRm9yQXN0cmFsc0luVmFyc0FuZENsYXNzZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJleHRlbmRlZEVzY2FwZXNGb3JBc3RyYWxzSW5WYXJzQW5kQ2xhc3Nlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwyQkFBMkI7QUFDM0IsSUFBUSxNQUFNLENBQUM7QUFDVixJQUFBLENBQUMsRUFBSSxFQUFFLGdCQUFBLENBQVU7QUFFdEIsSUFBSSxJQUFJLENBQUMsTUFBTSxFQUFFLEVBQUUsQ0FBQztJQUNYLE9BQU8sQ0FBQztBQUNqQixDQUFDO0tBQ0ksQ0FBQztJQUNELENBQUMsQ0FBQTtJQUFBLENBQUM7UUFBQSxHQUFHLENBQUE7UUFBQSxFQUFFLENBQUE7SUFBQSxDQUFDO0lBQUcsT0FBTyxDQUFDO0FBQ3hCLENBQUM7QUFFRDtJQUFBO0lBQ00sQ0FBQyxBQUFEO0lBQUEsVUFBQztBQUFELENBQUMsQUFBRCxBQUROLElBQ007QUFBQSxDQUFDO0lBQUEsR0FBRyxDQUFBO0lBQUEsRUFBRSxDQUFBO0FBQUEsQ0FBQztBQUFFLE1BQU0sQ0FBQztBQUNsQixXQUFXLEVBQUUsQ0FBQTtBQUFDLENBQUM7SUFDWCxJQUFJLENBQUMsQ0FBQTtJQUFDLENBQUMsQ0FBQTtJQUFBLENBQUM7UUFBQSxHQUFHLENBQUE7UUFBQSxFQUFFLENBQUE7SUFBQSxDQUFDO0lBQUcsUUFBUSxDQUFDO0FBQzlCLENBQUM7QUFDRCxPQUFPLEVBQUUsQ0FBQTtBQUFDLENBQUM7SUFDUCxPQUFPLElBQUksQ0FBQyxFQUFFLENBQUM7QUFDbkIsQ0FBQztBQUdMLE1BQU0sQ0FBQyxJQUFJLENBQUssQ0FBQTtBQUFDLElBQUksR0FBRyxFQUFFLENBQUMsQ0FBQTtBQUFDLENBQUMsQ0FBQTtBQUFBLENBQUM7SUFBQSxHQUFHLENBQUE7SUFBQSxFQUFFLENBQUE7QUFBQSxDQUFDO0FBQUMsQ0FBRSxJQUFJLEdBQUcsRUFBRSxDQUFDLE9BQU8sRUFBRSxDQUFDO0FBRTNELENBQUMsQ0FBQTtBQUFDLENBQUMsQ0FBQTtBQUFBLENBQUM7SUFBQSxHQUFHLENBQUE7SUFBQSxFQUFFLENBQUE7QUFBQSxDQUFDO0FBQUksR0FBRyxDQUFDIn0=,Ly8gVSsxMDJBNyBDQVJJQU4gTEVUVEVSIEEyCnZhciDtoIDtuqc6IHN0cmluZzsKdmFyIFx1ezEwMkE3fTogc3RyaW5nOwoKaWYgKE1hdGgucmFuZG9tKCkpIHsKICAgIO2ggO26pyA9ICJoZWxsbyI7Cn0KZWxzZSB7CiAgICBcdXsxMDJBN30gPSAiaGFsbG8iOwp9CgpjbGFzcyBGb28gewogICAgXHV7MTAyQTd9OiBzdHJpbmc7CiAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICB0aGlzLlx1ezEwMkE3fSA9ICIgd29ybGQiOwogICAgfQogICAgbWV0aG9kQSgpIHsKICAgICAgICByZXR1cm4gdGhpcy7toIDtuqc7CiAgICB9Cn0KCmV4cG9ydCB2YXIgX+2ggO26pyA9IG5ldyBGb28oKS5cdXsxMDJBN30gKyBuZXcgRm9vKCkubWV0aG9kQSgpOwoKX1x1ezEwMkE3fSArPSAiISI7Cg== +{"version":3,"file":"extendedEscapesForAstralsInVarsAndClasses.js","sourceRoot":"","sources":["extendedEscapesForAstralsInVarsAndClasses.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,IAAQ,MAAM,CAAC;AACV,IAAA,CAAC,EAAI,EAAE,gBAAA,CAAU;AAEtB,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;IACX,OAAO,CAAC;AACjB,CAAC;KACI,CAAC;IACD,CAAC,CAAA;IAAA,CAAC;QAAA,GAAG,CAAA;QAAA,EAAE,CAAA;IAAA,CAAC;IAAG,OAAO,CAAC;AACxB,CAAC;AAED;IAAA;IACM,CAAC,AAAD;IAAA,UAAC;AAAD,CAAC,AAAD,AADN,IACM;AAAA,CAAC;IAAA,GAAG,CAAA;IAAA,EAAE,CAAA;AAAA,CAAC;AAAE,MAAM,CAAC;AAClB,WAAW,EAAE,CAAA;AAAC,CAAC;IACX,IAAI,CAAC,EAAS,GAAG,QAAQ,CAAC;AAC9B,CAAC;AACD,OAAO,EAAE,CAAA;AAAC,CAAC;IACP,OAAO,IAAI,CAAC,EAAE,CAAC;AACnB,CAAC;AAGL,MAAM,CAAC,IAAI,CAAK,CAAA;AAAC,IAAI,GAAG,EAAE,CAAC,EAAS,GAAG,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;AAE3D,CAAC,CAAA;AAAC,CAAC,CAAA;AAAA,CAAC;IAAA,GAAG,CAAA;IAAA,EAAE,CAAA;AAAA,CAAC;AAAI,GAAG,CAAC"} +//// https://sokra.github.io/source-map-visualization#base64,Ly8gVSsxMDJBNyBDQVJJQU4gTEVUVEVSIEEyDQp2YXIgc3RyaW5nOw0KdmFyIHUsIEE3ID0gKHZvaWQgMClbMTAyXTsNCmlmIChNYXRoLnJhbmRvbSgpKSB7DQogICAgImhlbGxvIjsNCn0NCmVsc2Ugew0KICAgIHU7DQogICAgew0KICAgICAgICAxMDI7DQogICAgICAgIEE3Ow0KICAgIH0NCiAgICAiaGFsbG8iOw0KfQ0KdmFyIEZvbyA9IC8qKiBAY2xhc3MgKi8gKGZ1bmN0aW9uICgpIHsNCiAgICBmdW5jdGlvbiBGb28oKSB7DQogICAgfQ0KICAgIHJldHVybiBGb287DQp9KCkpOw0Kew0KICAgIDEwMjsNCiAgICBBNzsNCn0NCnN0cmluZzsNCmNvbnN0cnVjdG9yKCk7DQp7DQogICAgdGhpcy7toIDtuqcgPSAiIHdvcmxkIjsNCn0NCm1ldGhvZEEoKTsNCnsNCiAgICByZXR1cm4gdGhpcy7toIDtuqc7DQp9DQpleHBvcnQgdmFyIF87DQpuZXcgRm9vKCku7aCA7bqnICsgbmV3IEZvbygpLm1ldGhvZEEoKTsNCl87DQp1Ow0Kew0KICAgIDEwMjsNCiAgICBBNzsNCn0NCiIhIjsNCi8vIyBzb3VyY2VNYXBwaW5nVVJMPWV4dGVuZGVkRXNjYXBlc0ZvckFzdHJhbHNJblZhcnNBbmRDbGFzc2VzLmpzLm1hcA==,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXh0ZW5kZWRFc2NhcGVzRm9yQXN0cmFsc0luVmFyc0FuZENsYXNzZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJleHRlbmRlZEVzY2FwZXNGb3JBc3RyYWxzSW5WYXJzQW5kQ2xhc3Nlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwyQkFBMkI7QUFDM0IsSUFBUSxNQUFNLENBQUM7QUFDVixJQUFBLENBQUMsRUFBSSxFQUFFLGdCQUFBLENBQVU7QUFFdEIsSUFBSSxJQUFJLENBQUMsTUFBTSxFQUFFLEVBQUUsQ0FBQztJQUNYLE9BQU8sQ0FBQztBQUNqQixDQUFDO0tBQ0ksQ0FBQztJQUNELENBQUMsQ0FBQTtJQUFBLENBQUM7UUFBQSxHQUFHLENBQUE7UUFBQSxFQUFFLENBQUE7SUFBQSxDQUFDO0lBQUcsT0FBTyxDQUFDO0FBQ3hCLENBQUM7QUFFRDtJQUFBO0lBQ00sQ0FBQyxBQUFEO0lBQUEsVUFBQztBQUFELENBQUMsQUFBRCxBQUROLElBQ007QUFBQSxDQUFDO0lBQUEsR0FBRyxDQUFBO0lBQUEsRUFBRSxDQUFBO0FBQUEsQ0FBQztBQUFFLE1BQU0sQ0FBQztBQUNsQixXQUFXLEVBQUUsQ0FBQTtBQUFDLENBQUM7SUFDWCxJQUFJLENBQUMsRUFBUyxHQUFHLFFBQVEsQ0FBQztBQUM5QixDQUFDO0FBQ0QsT0FBTyxFQUFFLENBQUE7QUFBQyxDQUFDO0lBQ1AsT0FBTyxJQUFJLENBQUMsRUFBRSxDQUFDO0FBQ25CLENBQUM7QUFHTCxNQUFNLENBQUMsSUFBSSxDQUFLLENBQUE7QUFBQyxJQUFJLEdBQUcsRUFBRSxDQUFDLEVBQVMsR0FBRyxJQUFJLEdBQUcsRUFBRSxDQUFDLE9BQU8sRUFBRSxDQUFDO0FBRTNELENBQUMsQ0FBQTtBQUFDLENBQUMsQ0FBQTtBQUFBLENBQUM7SUFBQSxHQUFHLENBQUE7SUFBQSxFQUFFLENBQUE7QUFBQSxDQUFDO0FBQUksR0FBRyxDQUFDIn0=,Ly8gVSsxMDJBNyBDQVJJQU4gTEVUVEVSIEEyCnZhciDtoIDtuqc6IHN0cmluZzsKdmFyIFx1ezEwMkE3fTogc3RyaW5nOwoKaWYgKE1hdGgucmFuZG9tKCkpIHsKICAgIO2ggO26pyA9ICJoZWxsbyI7Cn0KZWxzZSB7CiAgICBcdXsxMDJBN30gPSAiaGFsbG8iOwp9CgpjbGFzcyBGb28gewogICAgXHV7MTAyQTd9OiBzdHJpbmc7CiAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICB0aGlzLlx1ezEwMkE3fSA9ICIgd29ybGQiOwogICAgfQogICAgbWV0aG9kQSgpIHsKICAgICAgICByZXR1cm4gdGhpcy7toIDtuqc7CiAgICB9Cn0KCmV4cG9ydCB2YXIgX+2ggO26pyA9IG5ldyBGb28oKS5cdXsxMDJBN30gKyBuZXcgRm9vKCkubWV0aG9kQSgpOwoKX1x1ezEwMkE3fSArPSAiISI7Cg== //// [astralAsSurrogatePair.js.map] {"version":3,"file":"astralAsSurrogatePair.js","sourceRoot":"","sources":["astralAsSurrogatePair.ts"],"names":[],"mappings":""} diff --git a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).sourcemap.txt b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).sourcemap.txt index 402cd48063928..e554e8138aea4 100644 --- a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).sourcemap.txt +++ b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).sourcemap.txt @@ -312,88 +312,35 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts >>>{ 1 > 2 >^ -3 > ^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^-> 1 > 2 >{ 1 >Emitted(26, 1) Source(14, 19) + SourceIndex(0) 2 >Emitted(26, 2) Source(14, 20) + SourceIndex(0) --- ->>> this.; +>>> this.𐊧 = " world"; 1->^^^^ 2 > ^^^^ 3 > ^ -4 > ^ +4 > ^^ +5 > ^^^ +6 > ^^^^^^^^ +7 > ^ 1-> > 2 > this 3 > . -4 > +4 > \u{102A7} +5 > = +6 > " world" +7 > ; 1->Emitted(27, 5) Source(15, 9) + SourceIndex(0) 2 >Emitted(27, 9) Source(15, 13) + SourceIndex(0) 3 >Emitted(27, 10) Source(15, 14) + SourceIndex(0) -4 >Emitted(27, 11) Source(15, 14) + SourceIndex(0) ---- ->>> u; -1 >^^^^ -2 > ^ -3 > ^ -1 >\ -2 > u -3 > -1 >Emitted(28, 5) Source(15, 15) + SourceIndex(0) -2 >Emitted(28, 6) Source(15, 16) + SourceIndex(0) -3 >Emitted(28, 7) Source(15, 16) + SourceIndex(0) ---- ->>> { -1 >^^^^ -2 > ^ -3 > ^^^^^^^^-> -1 > -2 > { -1 >Emitted(29, 5) Source(15, 16) + SourceIndex(0) -2 >Emitted(29, 6) Source(15, 17) + SourceIndex(0) ---- ->>> 102; -1->^^^^^^^^ -2 > ^^^ -3 > ^ -1-> -2 > 102 -3 > -1->Emitted(30, 9) Source(15, 17) + SourceIndex(0) -2 >Emitted(30, 12) Source(15, 20) + SourceIndex(0) -3 >Emitted(30, 13) Source(15, 20) + SourceIndex(0) ---- ->>> A7; -1 >^^^^^^^^ -2 > ^^ -3 > ^ -1 > -2 > A7 -3 > -1 >Emitted(31, 9) Source(15, 20) + SourceIndex(0) -2 >Emitted(31, 11) Source(15, 22) + SourceIndex(0) -3 >Emitted(31, 12) Source(15, 22) + SourceIndex(0) ---- ->>> } -1 >^^^^ -2 > ^ -3 > ^^^^^^^^^-> -1 > -2 > } -1 >Emitted(32, 5) Source(15, 22) + SourceIndex(0) -2 >Emitted(32, 6) Source(15, 23) + SourceIndex(0) ---- ->>> " world"; -1->^^^^ -2 > ^^^^^^^^ -3 > ^ -1-> = -2 > " world" -3 > ; -1->Emitted(33, 5) Source(15, 26) + SourceIndex(0) -2 >Emitted(33, 13) Source(15, 34) + SourceIndex(0) -3 >Emitted(33, 14) Source(15, 35) + SourceIndex(0) +4 >Emitted(27, 12) Source(15, 23) + SourceIndex(0) +5 >Emitted(27, 15) Source(15, 26) + SourceIndex(0) +6 >Emitted(27, 23) Source(15, 34) + SourceIndex(0) +7 >Emitted(27, 24) Source(15, 35) + SourceIndex(0) --- >>>} 1 > @@ -402,8 +349,8 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts 1 > > 2 >} -1 >Emitted(34, 1) Source(16, 5) + SourceIndex(0) -2 >Emitted(34, 2) Source(16, 6) + SourceIndex(0) +1 >Emitted(28, 1) Source(16, 5) + SourceIndex(0) +2 >Emitted(28, 2) Source(16, 6) + SourceIndex(0) --- >>>methodA(); 1-> @@ -415,10 +362,10 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts 2 >methodA 3 > () 4 > -1->Emitted(35, 1) Source(17, 5) + SourceIndex(0) -2 >Emitted(35, 8) Source(17, 12) + SourceIndex(0) -3 >Emitted(35, 10) Source(17, 14) + SourceIndex(0) -4 >Emitted(35, 11) Source(17, 14) + SourceIndex(0) +1->Emitted(29, 1) Source(17, 5) + SourceIndex(0) +2 >Emitted(29, 8) Source(17, 12) + SourceIndex(0) +3 >Emitted(29, 10) Source(17, 14) + SourceIndex(0) +4 >Emitted(29, 11) Source(17, 14) + SourceIndex(0) --- >>>{ 1 > @@ -426,8 +373,8 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts 3 > ^^^^^^^^^^^^^^^^^^^-> 1 > 2 >{ -1 >Emitted(36, 1) Source(17, 15) + SourceIndex(0) -2 >Emitted(36, 2) Source(17, 16) + SourceIndex(0) +1 >Emitted(30, 1) Source(17, 15) + SourceIndex(0) +2 >Emitted(30, 2) Source(17, 16) + SourceIndex(0) --- >>> return this.𐊧; 1->^^^^ @@ -443,12 +390,12 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts 4 > . 5 > 𐊧 6 > ; -1->Emitted(37, 5) Source(18, 9) + SourceIndex(0) -2 >Emitted(37, 12) Source(18, 16) + SourceIndex(0) -3 >Emitted(37, 16) Source(18, 20) + SourceIndex(0) -4 >Emitted(37, 17) Source(18, 21) + SourceIndex(0) -5 >Emitted(37, 19) Source(18, 23) + SourceIndex(0) -6 >Emitted(37, 20) Source(18, 24) + SourceIndex(0) +1->Emitted(31, 5) Source(18, 9) + SourceIndex(0) +2 >Emitted(31, 12) Source(18, 16) + SourceIndex(0) +3 >Emitted(31, 16) Source(18, 20) + SourceIndex(0) +4 >Emitted(31, 17) Source(18, 21) + SourceIndex(0) +5 >Emitted(31, 19) Source(18, 23) + SourceIndex(0) +6 >Emitted(31, 20) Source(18, 24) + SourceIndex(0) --- >>>} 1 > @@ -457,8 +404,8 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts 1 > > 2 >} -1 >Emitted(38, 1) Source(19, 5) + SourceIndex(0) -2 >Emitted(38, 2) Source(19, 6) + SourceIndex(0) +1 >Emitted(32, 1) Source(19, 5) + SourceIndex(0) +2 >Emitted(32, 2) Source(19, 6) + SourceIndex(0) --- >>>export var _; 1-> @@ -467,6 +414,7 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts 4 > ^^^^ 5 > ^ 6 > ^ +7 > ^^^^^^^^^^^^^^^^^^^^^^^-> 1-> >} > @@ -476,112 +424,56 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts 4 > var 5 > _𐊧 = 6 > -1->Emitted(39, 1) Source(22, 1) + SourceIndex(0) -2 >Emitted(39, 7) Source(22, 7) + SourceIndex(0) -3 >Emitted(39, 8) Source(22, 8) + SourceIndex(0) -4 >Emitted(39, 12) Source(22, 12) + SourceIndex(0) -5 >Emitted(39, 13) Source(22, 17) + SourceIndex(0) -6 >Emitted(39, 14) Source(22, 17) + SourceIndex(0) ---- ->>>new Foo().; -1 > +1->Emitted(33, 1) Source(22, 1) + SourceIndex(0) +2 >Emitted(33, 7) Source(22, 7) + SourceIndex(0) +3 >Emitted(33, 8) Source(22, 8) + SourceIndex(0) +4 >Emitted(33, 12) Source(22, 12) + SourceIndex(0) +5 >Emitted(33, 13) Source(22, 17) + SourceIndex(0) +6 >Emitted(33, 14) Source(22, 17) + SourceIndex(0) +--- +>>>new Foo().𐊧 + new Foo().methodA(); +1-> 2 >^^^^ 3 > ^^^ 4 > ^^ 5 > ^ -6 > ^ -1 > +6 > ^^ +7 > ^^^ +8 > ^^^^ +9 > ^^^ +10> ^^ +11> ^ +12> ^^^^^^^ +13> ^^ +14> ^ +1-> 2 >new 3 > Foo 4 > () 5 > . -6 > -1 >Emitted(40, 1) Source(22, 18) + SourceIndex(0) -2 >Emitted(40, 5) Source(22, 22) + SourceIndex(0) -3 >Emitted(40, 8) Source(22, 25) + SourceIndex(0) -4 >Emitted(40, 10) Source(22, 27) + SourceIndex(0) -5 >Emitted(40, 11) Source(22, 28) + SourceIndex(0) -6 >Emitted(40, 12) Source(22, 28) + SourceIndex(0) ---- ->>>u; -1 > -2 >^ -3 > ^ -1 >\ -2 >u -3 > -1 >Emitted(41, 1) Source(22, 29) + SourceIndex(0) -2 >Emitted(41, 2) Source(22, 30) + SourceIndex(0) -3 >Emitted(41, 3) Source(22, 30) + SourceIndex(0) ---- ->>>{ -1 > -2 >^ -3 > ^^^^^^^^-> -1 > -2 >{ -1 >Emitted(42, 1) Source(22, 30) + SourceIndex(0) -2 >Emitted(42, 2) Source(22, 31) + SourceIndex(0) ---- ->>> 102; -1->^^^^ -2 > ^^^ -3 > ^ -1-> -2 > 102 -3 > -1->Emitted(43, 5) Source(22, 31) + SourceIndex(0) -2 >Emitted(43, 8) Source(22, 34) + SourceIndex(0) -3 >Emitted(43, 9) Source(22, 34) + SourceIndex(0) ---- ->>> A7; -1 >^^^^ -2 > ^^ -3 > ^ -1 > -2 > A7 -3 > -1 >Emitted(44, 5) Source(22, 34) + SourceIndex(0) -2 >Emitted(44, 7) Source(22, 36) + SourceIndex(0) -3 >Emitted(44, 8) Source(22, 36) + SourceIndex(0) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -1 >Emitted(45, 1) Source(22, 36) + SourceIndex(0) -2 >Emitted(45, 2) Source(22, 37) + SourceIndex(0) ---- ->>>+new Foo().methodA(); -1-> -2 >^ -3 > ^^^^ -4 > ^^^ -5 > ^^ -6 > ^ -7 > ^^^^^^^ -8 > ^^ -9 > ^ -1-> -2 >+ -3 > new -4 > Foo -5 > () -6 > . -7 > methodA -8 > () -9 > ; -1->Emitted(46, 1) Source(22, 38) + SourceIndex(0) -2 >Emitted(46, 2) Source(22, 40) + SourceIndex(0) -3 >Emitted(46, 6) Source(22, 44) + SourceIndex(0) -4 >Emitted(46, 9) Source(22, 47) + SourceIndex(0) -5 >Emitted(46, 11) Source(22, 49) + SourceIndex(0) -6 >Emitted(46, 12) Source(22, 50) + SourceIndex(0) -7 >Emitted(46, 19) Source(22, 57) + SourceIndex(0) -8 >Emitted(46, 21) Source(22, 59) + SourceIndex(0) -9 >Emitted(46, 22) Source(22, 60) + SourceIndex(0) +6 > \u{102A7} +7 > + +8 > new +9 > Foo +10> () +11> . +12> methodA +13> () +14> ; +1->Emitted(34, 1) Source(22, 18) + SourceIndex(0) +2 >Emitted(34, 5) Source(22, 22) + SourceIndex(0) +3 >Emitted(34, 8) Source(22, 25) + SourceIndex(0) +4 >Emitted(34, 10) Source(22, 27) + SourceIndex(0) +5 >Emitted(34, 11) Source(22, 28) + SourceIndex(0) +6 >Emitted(34, 13) Source(22, 37) + SourceIndex(0) +7 >Emitted(34, 16) Source(22, 40) + SourceIndex(0) +8 >Emitted(34, 20) Source(22, 44) + SourceIndex(0) +9 >Emitted(34, 23) Source(22, 47) + SourceIndex(0) +10>Emitted(34, 25) Source(22, 49) + SourceIndex(0) +11>Emitted(34, 26) Source(22, 50) + SourceIndex(0) +12>Emitted(34, 33) Source(22, 57) + SourceIndex(0) +13>Emitted(34, 35) Source(22, 59) + SourceIndex(0) +14>Emitted(34, 36) Source(22, 60) + SourceIndex(0) --- >>>_; 1 > @@ -593,9 +485,9 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts > 2 >_ 3 > -1 >Emitted(47, 1) Source(24, 1) + SourceIndex(0) -2 >Emitted(47, 2) Source(24, 2) + SourceIndex(0) -3 >Emitted(47, 3) Source(24, 2) + SourceIndex(0) +1 >Emitted(35, 1) Source(24, 1) + SourceIndex(0) +2 >Emitted(35, 2) Source(24, 2) + SourceIndex(0) +3 >Emitted(35, 3) Source(24, 2) + SourceIndex(0) --- >>>u; 1-> @@ -604,9 +496,9 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts 1->\ 2 >u 3 > -1->Emitted(48, 1) Source(24, 3) + SourceIndex(0) -2 >Emitted(48, 2) Source(24, 4) + SourceIndex(0) -3 >Emitted(48, 3) Source(24, 4) + SourceIndex(0) +1->Emitted(36, 1) Source(24, 3) + SourceIndex(0) +2 >Emitted(36, 2) Source(24, 4) + SourceIndex(0) +3 >Emitted(36, 3) Source(24, 4) + SourceIndex(0) --- >>>{ 1 > @@ -614,8 +506,8 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts 3 > ^^^^^^^^-> 1 > 2 >{ -1 >Emitted(49, 1) Source(24, 4) + SourceIndex(0) -2 >Emitted(49, 2) Source(24, 5) + SourceIndex(0) +1 >Emitted(37, 1) Source(24, 4) + SourceIndex(0) +2 >Emitted(37, 2) Source(24, 5) + SourceIndex(0) --- >>> 102; 1->^^^^ @@ -624,9 +516,9 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts 1-> 2 > 102 3 > -1->Emitted(50, 5) Source(24, 5) + SourceIndex(0) -2 >Emitted(50, 8) Source(24, 8) + SourceIndex(0) -3 >Emitted(50, 9) Source(24, 8) + SourceIndex(0) +1->Emitted(38, 5) Source(24, 5) + SourceIndex(0) +2 >Emitted(38, 8) Source(24, 8) + SourceIndex(0) +3 >Emitted(38, 9) Source(24, 8) + SourceIndex(0) --- >>> A7; 1 >^^^^ @@ -635,9 +527,9 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts 1 > 2 > A7 3 > -1 >Emitted(51, 5) Source(24, 8) + SourceIndex(0) -2 >Emitted(51, 7) Source(24, 10) + SourceIndex(0) -3 >Emitted(51, 8) Source(24, 10) + SourceIndex(0) +1 >Emitted(39, 5) Source(24, 8) + SourceIndex(0) +2 >Emitted(39, 7) Source(24, 10) + SourceIndex(0) +3 >Emitted(39, 8) Source(24, 10) + SourceIndex(0) --- >>>} 1 > @@ -645,8 +537,8 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts 3 > ^^^^-> 1 > 2 >} -1 >Emitted(52, 1) Source(24, 10) + SourceIndex(0) -2 >Emitted(52, 2) Source(24, 11) + SourceIndex(0) +1 >Emitted(40, 1) Source(24, 10) + SourceIndex(0) +2 >Emitted(40, 2) Source(24, 11) + SourceIndex(0) --- >>>"!"; 1-> @@ -656,9 +548,9 @@ sourceFile:extendedEscapesForAstralsInVarsAndClasses.ts 1-> += 2 >"!" 3 > ; -1->Emitted(53, 1) Source(24, 15) + SourceIndex(0) -2 >Emitted(53, 4) Source(24, 18) + SourceIndex(0) -3 >Emitted(53, 5) Source(24, 19) + SourceIndex(0) +1->Emitted(41, 1) Source(24, 15) + SourceIndex(0) +2 >Emitted(41, 4) Source(24, 18) + SourceIndex(0) +3 >Emitted(41, 5) Source(24, 19) + SourceIndex(0) --- >>>//# sourceMappingURL=extendedEscapesForAstralsInVarsAndClasses.js.map=================================================================== JsFile: astralAsSurrogatePair.js diff --git a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).symbols b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).symbols index 2175e1b98cdc7..ff053519ced78 100644 --- a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).symbols +++ b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).symbols @@ -32,8 +32,6 @@ class Foo { constructor() { this.\u{102A7} = " world"; ->u : Symbol(u, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 2, 5)) ->A7 : Symbol(A7, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 2, 7)) } methodA() { return this.𐊧; @@ -43,8 +41,6 @@ class Foo { export var _𐊧 = new Foo().\u{102A7} + new Foo().methodA(); >_ : Symbol(_, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 21, 10)) >Foo : Symbol(Foo, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 9, 1)) ->u : Symbol(u, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 2, 5)) ->A7 : Symbol(A7, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 2, 7)) >Foo : Symbol(Foo, Decl(extendedEscapesForAstralsInVarsAndClasses.ts, 9, 1)) _\u{102A7} += "!"; diff --git a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).types b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).types index 25ad36211f7c3..15bc2ef7a0c5d 100644 --- a/tests/baselines/reference/unicodeEscapesInNames02(target=es5).types +++ b/tests/baselines/reference/unicodeEscapesInNames02(target=es5).types @@ -59,18 +59,14 @@ class Foo { > : ^^^ this.\u{102A7} = " world"; ->this. : any -> : ^^^ +>this.\u{102A7} = " world" : " world" +> : ^^^^^^^^ +>this.\u{102A7} : any +> : ^^^ >this : undefined > : ^^^^^^^^^ -> : any -> : ^^^ ->u : any -> : ^^^ ->102 : 102 -> : ^^^ ->A7 : string -> : ^^^^^^ +>\u{102A7} : any +> : ^^^ >" world" : " world" > : ^^^^^^^^ } @@ -93,22 +89,16 @@ class Foo { export var _𐊧 = new Foo().\u{102A7} + new Foo().methodA(); >_ : any > : ^^^ ->new Foo(). : any -> : ^^^ +>new Foo().\u{102A7} + new Foo().methodA() : any +> : ^^^ +>new Foo().\u{102A7} : any +> : ^^^ >new Foo() : Foo > : ^^^ >Foo : typeof Foo > : ^^^^^^^^^^ -> : any -> : ^^^ ->u : any -> : ^^^ ->102 : 102 -> : ^^^ ->A7 : string -> : ^^^^^^ ->+ new Foo().methodA() : number -> : ^^^^^^ +>\u{102A7} : any +> : ^^^ >new Foo().methodA() : any > : ^^^ >new Foo().methodA : any From da5df6ee8b47f69d91fe1c1ecf458017e46e9cc6 Mon Sep 17 00:00:00 2001 From: graphemecluster Date: Thu, 23 Jan 2025 19:11:51 +0800 Subject: [PATCH 2/4] Parse regular expression group names with surrogate pairs --- src/compiler/scanner.ts | 115 +++++-- ...pressionGroupNameUnicodeEscapes.errors.txt | 299 ++++++++++++++++++ ...egularExpressionGroupNameUnicodeEscapes.js | 114 +++++++ ...rExpressionGroupNameUnicodeEscapes.symbols | 66 ++++ ...larExpressionGroupNameUnicodeEscapes.types | 159 ++++++++++ ...egularExpressionGroupNameUnicodeEscapes.ts | 63 ++++ 6 files changed, 788 insertions(+), 28 deletions(-) create mode 100644 tests/baselines/reference/regularExpressionGroupNameUnicodeEscapes.errors.txt create mode 100644 tests/baselines/reference/regularExpressionGroupNameUnicodeEscapes.js create mode 100644 tests/baselines/reference/regularExpressionGroupNameUnicodeEscapes.symbols create mode 100644 tests/baselines/reference/regularExpressionGroupNameUnicodeEscapes.types create mode 100644 tests/cases/compiler/regularExpressionGroupNameUnicodeEscapes.ts diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 8223d5c56080e..4b4a3e6b74be0 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -974,7 +974,11 @@ export function isIdentifierStart(ch: number, languageVersion: ScriptTarget | un ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierStart(ch, languageVersion); } -export function isIdentifierPart(ch: number, languageVersion: ScriptTarget | undefined, identifierVariant?: LanguageVariant): boolean { +export function isIdentifierPart(ch: number, languageVersion: ScriptTarget | undefined, identifierVariant?: LanguageVariant): boolean; +/** @internal separate public and internal signatures so that identifierVariant can be passed directly from scanIdentifierParts */ +// eslint-disable-next-line @typescript-eslint/unified-signatures +export function isIdentifierPart(ch: number, languageVersion: ScriptTarget | undefined, identifierVariant?: LanguageVariant | "RegExpGroupName"): boolean; +export function isIdentifierPart(ch: number, languageVersion: ScriptTarget | undefined, identifierVariant?: LanguageVariant | "RegExpGroupName"): boolean { return isWordCharacter(ch) || ch === CharacterCodes.$ || // "-" is valid in JSX Identifiers. ":" is part of JSXNamespacedName but not JSXIdentifier. identifierVariant === LanguageVariant.JSX && ch === CharacterCodes.minus || @@ -1644,8 +1648,9 @@ export function createScanner( const escapedValue = parseInt(text.substring(start + 2, pos), 16); const escapedValueString = String.fromCharCode(escapedValue); if ( - flags & EscapeSequenceScanningFlags.AnyUnicodeMode && escapedValue >= 0xD800 && escapedValue <= 0xDBFF && - pos + 6 < end && text.substring(pos, pos + 2) === "\\u" && charCodeUnchecked(pos + 2) !== CharacterCodes.openBrace + flags & EscapeSequenceScanningFlags.AnyUnicodeMode && isLeadingSurrogate(escapedValue) && + pos + 6 < end && codePointUnchecked(pos) === CharacterCodes.backslash && + codePointUnchecked(pos + 1) === CharacterCodes.u && charCodeUnchecked(pos + 2) !== CharacterCodes.openBrace ) { // For regular expressions in any Unicode mode, \u HexLeadSurrogate \u HexTrailSurrogate is treated as a single character // for the purpose of determining whether a character class range is out of order @@ -1659,7 +1664,7 @@ export function createScanner( } } const nextEscapedValue = parseInt(text.substring(nextStart + 2, nextPos), 16); - if (nextEscapedValue >= 0xDC00 && nextEscapedValue <= 0xDFFF) { + if (isTrailingSurrogate(nextEscapedValue)) { pos = nextPos; return escapedValueString + String.fromCharCode(nextEscapedValue); } @@ -1777,33 +1782,55 @@ export function createScanner( return -1; } - function scanIdentifierParts(languageVersion: ScriptTarget, identifierVariant?: LanguageVariant): string { + function scanIdentifierParts(languageVersion: ScriptTarget, identifierVariant?: LanguageVariant | "RegExpGroupName"): string { let result = ""; let start = pos; while (pos < end) { - let ch = codePointUnchecked(pos); + const ch = codePointUnchecked(pos); if (isIdentifierPart(ch, languageVersion, identifierVariant)) { pos += charSize(ch); continue; } if (ch === CharacterCodes.backslash) { - ch = peekExtendedUnicodeEscape(); - if (ch >= 0 && isIdentifierPart(ch, languageVersion, identifierVariant)) { + const extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierPart(extendedCookedChar, languageVersion, identifierVariant)) { result += text.substring(start, pos); result += scanExtendedUnicodeEscape(/*shouldEmitInvalidEscapeError*/ true); + // scanExtendedUnicodeEscape advances pos for us start = pos; continue; } - ch = peekUnicodeEscape(); - if (ch >= 0 && isIdentifierPart(ch, languageVersion, identifierVariant)) { - tokenFlags |= TokenFlags.UnicodeEscape; - result += text.substring(start, pos); - result += String.fromCharCode(ch); - pos += 6; // Valid Unicode escape is always six characters - start = pos; - continue; + const cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0) { + if (isIdentifierPart(cookedChar, languageVersion, identifierVariant)) { + tokenFlags |= TokenFlags.UnicodeEscape; + result += text.substring(start, pos); + result += String.fromCharCode(cookedChar); + pos += 6; // Valid Unicode escape is always six characters + start = pos; + continue; + } + else if (identifierVariant === "RegExpGroupName" && isLeadingSurrogate(cookedChar) && codePointChecked(pos + 6) === CharacterCodes.backslash) { + pos += 6; + const nextCookedChar = peekUnicodeEscape(); + if (nextCookedChar >= 0 && isTrailingSurrogate(nextCookedChar)) { + const codePoint = utf16SurrogatePairToCodePoint(cookedChar, nextCookedChar); + if (isIdentifierPart(codePoint, languageVersion, identifierVariant)) { + // Unlike normal identifiers, group names in regular expressions, whether in Unicode mode or not, + // accepts \u HexLeadSurrogate \u HexTrailSurrogate as part of RegExpIdentifierName. + // See https://github.com/tc39/ecma262/pull/1869 for the change. + tokenFlags |= TokenFlags.UnicodeEscape; + result += text.substring(start, pos - 6); + result += utf16EncodeAsString(codePoint); + pos += 6; + start = pos; + continue; + } + } + pos -= 6; + } } } break; @@ -2370,7 +2397,7 @@ export function createScanner( return scanIdentifier(ScriptTarget.ESNext); } - function scanIdentifierStart(languageVersion: ScriptTarget): string { + function scanIdentifierStart(languageVersion: ScriptTarget, identifierVariant?: LanguageVariant | "RegExpGroupName"): string { const ch = codePointChecked(pos); if (ch === CharacterCodes.backslash) { const extendedCookedChar = peekExtendedUnicodeEscape(); @@ -2379,10 +2406,28 @@ export function createScanner( } const cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { - pos += 6; // Valid Unicode escape is always six characters - tokenFlags |= TokenFlags.UnicodeEscape; - return String.fromCharCode(cookedChar); + if (cookedChar >= 0) { + if (isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; // Valid Unicode escape is always six characters + tokenFlags |= TokenFlags.UnicodeEscape; + return String.fromCharCode(cookedChar); + } + else if (identifierVariant === "RegExpGroupName" && isLeadingSurrogate(cookedChar) && codePointChecked(pos + 6) === CharacterCodes.backslash) { + pos += 6; + const nextCookedChar = peekUnicodeEscape(); + if (nextCookedChar >= 0 && isTrailingSurrogate(nextCookedChar)) { + const codePoint = utf16SurrogatePairToCodePoint(cookedChar, nextCookedChar); + if (isIdentifierStart(codePoint, languageVersion)) { + // Unlike normal identifiers, group names in regular expressions, whether in Unicode mode or not, + // accepts \u HexLeadSurrogate \u HexTrailSurrogate as part of RegExpIdentifierName. + // See https://github.com/tc39/ecma262/pull/1869 for the change. + pos += 6; + tokenFlags |= TokenFlags.UnicodeEscape; + return utf16EncodeAsString(codePoint); + } + } + pos -= 6; + } } } else if (isIdentifierStart(ch, languageVersion)) { @@ -2392,8 +2437,8 @@ export function createScanner( return ""; } - function scanIdentifier(languageVersion: ScriptTarget, identifierVariant?: LanguageVariant) { - tokenValue = scanIdentifierStart(languageVersion); + function scanIdentifier(languageVersion: ScriptTarget, identifierVariant?: LanguageVariant | "RegExpGroupName") { + tokenValue = scanIdentifierStart(languageVersion, identifierVariant); if (tokenValue) { tokenValue += scanIdentifierParts(languageVersion, identifierVariant); return token = getIdentifierToken(); @@ -2963,7 +3008,7 @@ export function createScanner( function scanGroupName(isReference: boolean) { Debug.assertEqual(charCodeUnchecked(pos - 1), CharacterCodes.lessThan); tokenStart = pos; - if (!scanIdentifier(languageVersion)) { + if (!scanIdentifier(languageVersion, "RegExpGroupName")) { error(Diagnostics.Expected_a_capturing_group_name); } else if (isReference) { @@ -3975,16 +4020,16 @@ function charSize(ch: number) { return 1; } -// Derived from the 10.1.1 UTF16Encoding of the ES6 Spec. +// Derived from Section 11.1.1 UTF16EncodeCodePoint of the spec. function utf16EncodeAsStringFallback(codePoint: number) { Debug.assert(0x0 <= codePoint && codePoint <= 0x10FFFF); - if (codePoint <= 65535) { + if (codePoint <= 0xFFFF) { return String.fromCharCode(codePoint); } - const codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800; - const codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00; + const codeUnit1 = Math.floor((codePoint - 0x10000) / 0x400) + 0xD800; + const codeUnit2 = ((codePoint - 0x10000) % 0x400) + 0xDC00; return String.fromCharCode(codeUnit1, codeUnit2); } @@ -3996,6 +4041,20 @@ export function utf16EncodeAsString(codePoint: number): string { return utf16EncodeAsStringWorker(codePoint); } +// Derived from Section 11.1.3 UTF16SurrogatePairToCodePoint of the spec. +function utf16SurrogatePairToCodePoint(leadingSurrogate: number, trailingSurrogate: number) { + Debug.assert(isLeadingSurrogate(leadingSurrogate) && isTrailingSurrogate(trailingSurrogate)); + return (leadingSurrogate - 0xD800) * 0x400 + (trailingSurrogate - 0xDC00) + 0x10000; +} + +function isLeadingSurrogate(ch: number) { + return 0xD800 <= ch && ch <= 0xDBFF; +} + +function isTrailingSurrogate(ch: number) { + return 0xDC00 <= ch && ch <= 0xDFFF; +} + // Table 66: Non-binary Unicode property aliases and their canonical property names // https://tc39.es/ecma262/#table-nonbinary-unicode-properties // dprint-ignore diff --git a/tests/baselines/reference/regularExpressionGroupNameUnicodeEscapes.errors.txt b/tests/baselines/reference/regularExpressionGroupNameUnicodeEscapes.errors.txt new file mode 100644 index 0000000000000..07bc7d62d1954 --- /dev/null +++ b/tests/baselines/reference/regularExpressionGroupNameUnicodeEscapes.errors.txt @@ -0,0 +1,299 @@ +regularExpressionGroupNameUnicodeEscapes.ts(11,5): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(11,11): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(11,16): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(11,26): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(12,5): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(12,16): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(12,21): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(12,31): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(13,5): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(13,18): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(13,23): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(13,33): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(29,5): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(29,12): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(29,18): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(29,31): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(30,5): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(30,19): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(30,25): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(30,38): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(31,5): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(31,22): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(31,28): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(31,41): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(40,5): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(40,11): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(40,22): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(40,35): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(40,40): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(40,50): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(41,6): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(41,12): error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. +regularExpressionGroupNameUnicodeEscapes.ts(41,13): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(41,24): error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. +regularExpressionGroupNameUnicodeEscapes.ts(41,25): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(41,39): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(41,45): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(41,56): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(44,5): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(44,12): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(44,26): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(44,43): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(44,49): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(44,62): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(45,6): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(45,13): error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. +regularExpressionGroupNameUnicodeEscapes.ts(45,14): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(45,28): error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. +regularExpressionGroupNameUnicodeEscapes.ts(45,29): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(45,47): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(45,54): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(45,68): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(48,5): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(48,16): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(48,29): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(48,39): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(49,6): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(49,17): error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. +regularExpressionGroupNameUnicodeEscapes.ts(49,18): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(49,32): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(49,43): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(52,5): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(52,16): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(52,29): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(52,39): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(53,6): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(53,17): error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. +regularExpressionGroupNameUnicodeEscapes.ts(53,18): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(53,32): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(53,43): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(56,5): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(56,13): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionGroupNameUnicodeEscapes.ts(56,26): error TS1514: Expected a capturing group name. +regularExpressionGroupNameUnicodeEscapes.ts(56,34): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionGroupNameUnicodeEscapes.ts(57,6): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(57,14): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionGroupNameUnicodeEscapes.ts(57,28): error TS1005: '>' expected. +regularExpressionGroupNameUnicodeEscapes.ts(57,36): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + + +==== regularExpressionGroupNameUnicodeEscapes.ts (78 errors) ==== + // U+13A0 CHEROKEE LETTER A: character inside BMP with both the Unicode properties ID_Start and ID_Continue + /(?<Ꭰ>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/; + /(?<\u13A0>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/; + /(?<\u{13A0}>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/; + + /(?<_Ꭰ>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/; + /(?<_\u13A0>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/; + /(?<_\u{13A0}>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/; + + // U+19D4 NEW TAI LUE DIGIT FOUR: character inside BMP with only ID_Continue + /(?<α§”>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/; // invalid + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + /(?<\u19D4>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/; // invalid + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + /(?<\u{19D4}>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/; // invalid + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + + /(?<_α§”>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/; + /(?<_\u19D4>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/; + /(?<_\u{19D4}>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/; + + // U+102A7 CARIAN LETTER A2: character outside BMP with both ID_Start and ID_Continue + /(?<𐊧>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/; + /(?<\u{102A7}>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/; + /(?<\uD800\uDEA7>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/; + + /(?<_𐊧>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/; + /(?<_\u{102A7}>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/; + /(?<_\uD800\uDEA7>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/; + + // U+1113D CHAKMA DIGIT SEVEN: character outside BMP with only ID_Continue + /(?<π‘„½>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/; // invalid + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + /(?<\u{1113D}>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/; // invalid + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + /(?<\uD804\uDD3D>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/; // invalid + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + + /(?<_π‘„½>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/; + /(?<_\u{1113D}>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/; + /(?<_\uD804\uDD3D>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/; + + // The following cases are all invalid: + + // U+2F47 KANGXI RADICAL SUN: character inside BMP without both properties + /(?<⽇>)(?<\u2F47>)(?<\u{2F47}>)\k<⽇>\k<\u2F47>\k<\u{2F47}>/; + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + /(?<_⽇>)(?<_\u2F47>)(?<_\u{2F47}>)\k<_⽇>\k<_\u2F47>\k<_\u{2F47}>/; + +!!! error TS1005: '>' expected. + ~ +!!! error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. + +!!! error TS1005: '>' expected. + ~ +!!! error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. + +!!! error TS1005: '>' expected. + +!!! error TS1005: '>' expected. + +!!! error TS1005: '>' expected. + +!!! error TS1005: '>' expected. + + // U+1F31A NEW MOON WITH FACE: character outside BMP without both properties + /(?<🌚>)(?<\u{1F31A}>)(?<\uD83C\uDF1A>)\k<🌚>\k<\u{1F31A}>\k<\uD83C\uDF1A>/; + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + /(?<_🌚>)(?<_\u{1F31A}>)(?<_\uD83C\uDF1A>)\k<_🌚>\k<_\u{1F31A}>\k<_\uD83C\uDF1A>/; + +!!! error TS1005: '>' expected. + ~ +!!! error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. + +!!! error TS1005: '>' expected. + ~ +!!! error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. + +!!! error TS1005: '>' expected. + +!!! error TS1005: '>' expected. + +!!! error TS1005: '>' expected. + +!!! error TS1005: '>' expected. + + // Lone leading surrogate + /(?<\uD800>)(?<\u{D800}>)\k<\uD800>\k<\u{D800}>/; + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + /(?<_\uD800>)(?<_\u{D800}>)\k<_\uD800>\k<_\u{D800}>/; + +!!! error TS1005: '>' expected. + ~ +!!! error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. + +!!! error TS1005: '>' expected. + +!!! error TS1005: '>' expected. + +!!! error TS1005: '>' expected. + + // Lone trailing surrogate + /(?<\uDFFF>)(?<\u{DFFF}>)\k<\uDFFF>\k<\u{DFFF}>/; + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + +!!! error TS1514: Expected a capturing group name. + /(?<_\uDFFF>)(?<_\u{DFFF}>)\k<_\uDFFF>\k<_\u{DFFF}>/; + +!!! error TS1005: '>' expected. + ~ +!!! error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. + +!!! error TS1005: '>' expected. + +!!! error TS1005: '>' expected. + +!!! error TS1005: '>' expected. + + // Fake surrogate pair with extended Unicode escapes – invalid even if the intended character has both properties + /(?<\u{D800}\u{DC00}>)\k<\u{D800}\u{DC00}>/; + +!!! error TS1514: Expected a capturing group name. + ~~~~~~~~ +!!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1514: Expected a capturing group name. + ~~~~~~~~ +!!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + /(?<_\u{D800}\u{DC00}>)\k<_\u{D800}\u{DC00}>/; + +!!! error TS1005: '>' expected. + ~~~~~~~~ +!!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1005: '>' expected. + ~~~~~~~~ +!!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + + // Cases with Unicode escapes and extended Unicode escapes mixed + /(?)\k\k<\u{52}\u0065gE\u{78}p>\k<\u0052e\u0067\u{45}x\u{70}>/; + /(?<_RegExp>)\k<_RegExp>\k<_\u{52}\u0065gE\u{78}p>\k<_\u0052e\u0067\u{45}x\u{70}>/; + \ No newline at end of file diff --git a/tests/baselines/reference/regularExpressionGroupNameUnicodeEscapes.js b/tests/baselines/reference/regularExpressionGroupNameUnicodeEscapes.js new file mode 100644 index 0000000000000..7056ce8a1e915 --- /dev/null +++ b/tests/baselines/reference/regularExpressionGroupNameUnicodeEscapes.js @@ -0,0 +1,114 @@ +//// [tests/cases/compiler/regularExpressionGroupNameUnicodeEscapes.ts] //// + +//// [regularExpressionGroupNameUnicodeEscapes.ts] +// U+13A0 CHEROKEE LETTER A: character inside BMP with both the Unicode properties ID_Start and ID_Continue +/(?<Ꭰ>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/; +/(?<\u13A0>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/; +/(?<\u{13A0}>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/; + +/(?<_Ꭰ>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/; +/(?<_\u13A0>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/; +/(?<_\u{13A0}>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/; + +// U+19D4 NEW TAI LUE DIGIT FOUR: character inside BMP with only ID_Continue +/(?<α§”>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/; // invalid +/(?<\u19D4>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/; // invalid +/(?<\u{19D4}>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/; // invalid + +/(?<_α§”>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/; +/(?<_\u19D4>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/; +/(?<_\u{19D4}>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/; + +// U+102A7 CARIAN LETTER A2: character outside BMP with both ID_Start and ID_Continue +/(?<𐊧>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/; +/(?<\u{102A7}>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/; +/(?<\uD800\uDEA7>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/; + +/(?<_𐊧>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/; +/(?<_\u{102A7}>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/; +/(?<_\uD800\uDEA7>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/; + +// U+1113D CHAKMA DIGIT SEVEN: character outside BMP with only ID_Continue +/(?<π‘„½>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/; // invalid +/(?<\u{1113D}>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/; // invalid +/(?<\uD804\uDD3D>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/; // invalid + +/(?<_π‘„½>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/; +/(?<_\u{1113D}>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/; +/(?<_\uD804\uDD3D>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/; + +// The following cases are all invalid: + +// U+2F47 KANGXI RADICAL SUN: character inside BMP without both properties +/(?<⽇>)(?<\u2F47>)(?<\u{2F47}>)\k<⽇>\k<\u2F47>\k<\u{2F47}>/; +/(?<_⽇>)(?<_\u2F47>)(?<_\u{2F47}>)\k<_⽇>\k<_\u2F47>\k<_\u{2F47}>/; + +// U+1F31A NEW MOON WITH FACE: character outside BMP without both properties +/(?<🌚>)(?<\u{1F31A}>)(?<\uD83C\uDF1A>)\k<🌚>\k<\u{1F31A}>\k<\uD83C\uDF1A>/; +/(?<_🌚>)(?<_\u{1F31A}>)(?<_\uD83C\uDF1A>)\k<_🌚>\k<_\u{1F31A}>\k<_\uD83C\uDF1A>/; + +// Lone leading surrogate +/(?<\uD800>)(?<\u{D800}>)\k<\uD800>\k<\u{D800}>/; +/(?<_\uD800>)(?<_\u{D800}>)\k<_\uD800>\k<_\u{D800}>/; + +// Lone trailing surrogate +/(?<\uDFFF>)(?<\u{DFFF}>)\k<\uDFFF>\k<\u{DFFF}>/; +/(?<_\uDFFF>)(?<_\u{DFFF}>)\k<_\uDFFF>\k<_\u{DFFF}>/; + +// Fake surrogate pair with extended Unicode escapes – invalid even if the intended character has both properties +/(?<\u{D800}\u{DC00}>)\k<\u{D800}\u{DC00}>/; +/(?<_\u{D800}\u{DC00}>)\k<_\u{D800}\u{DC00}>/; + +// Cases with Unicode escapes and extended Unicode escapes mixed +/(?)\k\k<\u{52}\u0065gE\u{78}p>\k<\u0052e\u0067\u{45}x\u{70}>/; +/(?<_RegExp>)\k<_RegExp>\k<_\u{52}\u0065gE\u{78}p>\k<_\u0052e\u0067\u{45}x\u{70}>/; + + +//// [regularExpressionGroupNameUnicodeEscapes.js] +// U+13A0 CHEROKEE LETTER A: character inside BMP with both the Unicode properties ID_Start and ID_Continue +/(?<Ꭰ>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/; +/(?<\u13A0>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/; +/(?<\u{13A0}>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/; +/(?<_Ꭰ>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/; +/(?<_\u13A0>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/; +/(?<_\u{13A0}>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/; +// U+19D4 NEW TAI LUE DIGIT FOUR: character inside BMP with only ID_Continue +/(?<α§”>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/; // invalid +/(?<\u19D4>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/; // invalid +/(?<\u{19D4}>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/; // invalid +/(?<_α§”>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/; +/(?<_\u19D4>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/; +/(?<_\u{19D4}>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/; +// U+102A7 CARIAN LETTER A2: character outside BMP with both ID_Start and ID_Continue +/(?<𐊧>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/; +/(?<\u{102A7}>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/; +/(?<\uD800\uDEA7>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/; +/(?<_𐊧>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/; +/(?<_\u{102A7}>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/; +/(?<_\uD800\uDEA7>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/; +// U+1113D CHAKMA DIGIT SEVEN: character outside BMP with only ID_Continue +/(?<π‘„½>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/; // invalid +/(?<\u{1113D}>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/; // invalid +/(?<\uD804\uDD3D>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/; // invalid +/(?<_π‘„½>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/; +/(?<_\u{1113D}>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/; +/(?<_\uD804\uDD3D>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/; +// The following cases are all invalid: +// U+2F47 KANGXI RADICAL SUN: character inside BMP without both properties +/(?<⽇>)(?<\u2F47>)(?<\u{2F47}>)\k<⽇>\k<\u2F47>\k<\u{2F47}>/; +/(?<_⽇>)(?<_\u2F47>)(?<_\u{2F47}>)\k<_⽇>\k<_\u2F47>\k<_\u{2F47}>/; +// U+1F31A NEW MOON WITH FACE: character outside BMP without both properties +/(?<🌚>)(?<\u{1F31A}>)(?<\uD83C\uDF1A>)\k<🌚>\k<\u{1F31A}>\k<\uD83C\uDF1A>/; +/(?<_🌚>)(?<_\u{1F31A}>)(?<_\uD83C\uDF1A>)\k<_🌚>\k<_\u{1F31A}>\k<_\uD83C\uDF1A>/; +// Lone leading surrogate +/(?<\uD800>)(?<\u{D800}>)\k<\uD800>\k<\u{D800}>/; +/(?<_\uD800>)(?<_\u{D800}>)\k<_\uD800>\k<_\u{D800}>/; +// Lone trailing surrogate +/(?<\uDFFF>)(?<\u{DFFF}>)\k<\uDFFF>\k<\u{DFFF}>/; +/(?<_\uDFFF>)(?<_\u{DFFF}>)\k<_\uDFFF>\k<_\u{DFFF}>/; +// Fake surrogate pair with extended Unicode escapes – invalid even if the intended character has both properties +/(?<\u{D800}\u{DC00}>)\k<\u{D800}\u{DC00}>/; +/(?<_\u{D800}\u{DC00}>)\k<_\u{D800}\u{DC00}>/; +// Cases with Unicode escapes and extended Unicode escapes mixed +/(?)\k\k<\u{52}\u0065gE\u{78}p>\k<\u0052e\u0067\u{45}x\u{70}>/; +/(?<_RegExp>)\k<_RegExp>\k<_\u{52}\u0065gE\u{78}p>\k<_\u0052e\u0067\u{45}x\u{70}>/; diff --git a/tests/baselines/reference/regularExpressionGroupNameUnicodeEscapes.symbols b/tests/baselines/reference/regularExpressionGroupNameUnicodeEscapes.symbols new file mode 100644 index 0000000000000..4830c815768f1 --- /dev/null +++ b/tests/baselines/reference/regularExpressionGroupNameUnicodeEscapes.symbols @@ -0,0 +1,66 @@ +//// [tests/cases/compiler/regularExpressionGroupNameUnicodeEscapes.ts] //// + +=== regularExpressionGroupNameUnicodeEscapes.ts === + +// U+13A0 CHEROKEE LETTER A: character inside BMP with both the Unicode properties ID_Start and ID_Continue +/(?<Ꭰ>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/; +/(?<\u13A0>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/; +/(?<\u{13A0}>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/; + +/(?<_Ꭰ>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/; +/(?<_\u13A0>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/; +/(?<_\u{13A0}>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/; + +// U+19D4 NEW TAI LUE DIGIT FOUR: character inside BMP with only ID_Continue +/(?<α§”>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/; // invalid +/(?<\u19D4>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/; // invalid +/(?<\u{19D4}>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/; // invalid + +/(?<_α§”>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/; +/(?<_\u19D4>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/; +/(?<_\u{19D4}>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/; + +// U+102A7 CARIAN LETTER A2: character outside BMP with both ID_Start and ID_Continue +/(?<𐊧>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/; +/(?<\u{102A7}>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/; +/(?<\uD800\uDEA7>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/; + +/(?<_𐊧>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/; +/(?<_\u{102A7}>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/; +/(?<_\uD800\uDEA7>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/; + +// U+1113D CHAKMA DIGIT SEVEN: character outside BMP with only ID_Continue +/(?<π‘„½>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/; // invalid +/(?<\u{1113D}>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/; // invalid +/(?<\uD804\uDD3D>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/; // invalid + +/(?<_π‘„½>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/; +/(?<_\u{1113D}>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/; +/(?<_\uD804\uDD3D>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/; + +// The following cases are all invalid: + +// U+2F47 KANGXI RADICAL SUN: character inside BMP without both properties +/(?<⽇>)(?<\u2F47>)(?<\u{2F47}>)\k<⽇>\k<\u2F47>\k<\u{2F47}>/; +/(?<_⽇>)(?<_\u2F47>)(?<_\u{2F47}>)\k<_⽇>\k<_\u2F47>\k<_\u{2F47}>/; + +// U+1F31A NEW MOON WITH FACE: character outside BMP without both properties +/(?<🌚>)(?<\u{1F31A}>)(?<\uD83C\uDF1A>)\k<🌚>\k<\u{1F31A}>\k<\uD83C\uDF1A>/; +/(?<_🌚>)(?<_\u{1F31A}>)(?<_\uD83C\uDF1A>)\k<_🌚>\k<_\u{1F31A}>\k<_\uD83C\uDF1A>/; + +// Lone leading surrogate +/(?<\uD800>)(?<\u{D800}>)\k<\uD800>\k<\u{D800}>/; +/(?<_\uD800>)(?<_\u{D800}>)\k<_\uD800>\k<_\u{D800}>/; + +// Lone trailing surrogate +/(?<\uDFFF>)(?<\u{DFFF}>)\k<\uDFFF>\k<\u{DFFF}>/; +/(?<_\uDFFF>)(?<_\u{DFFF}>)\k<_\uDFFF>\k<_\u{DFFF}>/; + +// Fake surrogate pair with extended Unicode escapes – invalid even if the intended character has both properties +/(?<\u{D800}\u{DC00}>)\k<\u{D800}\u{DC00}>/; +/(?<_\u{D800}\u{DC00}>)\k<_\u{D800}\u{DC00}>/; + +// Cases with Unicode escapes and extended Unicode escapes mixed +/(?)\k\k<\u{52}\u0065gE\u{78}p>\k<\u0052e\u0067\u{45}x\u{70}>/; +/(?<_RegExp>)\k<_RegExp>\k<_\u{52}\u0065gE\u{78}p>\k<_\u0052e\u0067\u{45}x\u{70}>/; + diff --git a/tests/baselines/reference/regularExpressionGroupNameUnicodeEscapes.types b/tests/baselines/reference/regularExpressionGroupNameUnicodeEscapes.types new file mode 100644 index 0000000000000..801ddef638c95 --- /dev/null +++ b/tests/baselines/reference/regularExpressionGroupNameUnicodeEscapes.types @@ -0,0 +1,159 @@ +//// [tests/cases/compiler/regularExpressionGroupNameUnicodeEscapes.ts] //// + +=== regularExpressionGroupNameUnicodeEscapes.ts === +// U+13A0 CHEROKEE LETTER A: character inside BMP with both the Unicode properties ID_Start and ID_Continue +/(?<Ꭰ>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/; +>/(?<Ꭰ>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/ : RegExp +> : ^^^^^^ + +/(?<\u13A0>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/; +>/(?<\u13A0>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/ : RegExp +> : ^^^^^^ + +/(?<\u{13A0}>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/; +>/(?<\u{13A0}>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/ : RegExp +> : ^^^^^^ + +/(?<_Ꭰ>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/; +>/(?<_Ꭰ>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/ : RegExp +> : ^^^^^^ + +/(?<_\u13A0>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/; +>/(?<_\u13A0>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/ : RegExp +> : ^^^^^^ + +/(?<_\u{13A0}>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/; +>/(?<_\u{13A0}>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/ : RegExp +> : ^^^^^^ + +// U+19D4 NEW TAI LUE DIGIT FOUR: character inside BMP with only ID_Continue +/(?<α§”>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/; // invalid +>/(?<α§”>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/ : RegExp +> : ^^^^^^ + +/(?<\u19D4>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/; // invalid +>/(?<\u19D4>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/ : RegExp +> : ^^^^^^ + +/(?<\u{19D4}>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/; // invalid +>/(?<\u{19D4}>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/ : RegExp +> : ^^^^^^ + +/(?<_α§”>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/; +>/(?<_α§”>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/ : RegExp +> : ^^^^^^ + +/(?<_\u19D4>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/; +>/(?<_\u19D4>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/ : RegExp +> : ^^^^^^ + +/(?<_\u{19D4}>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/; +>/(?<_\u{19D4}>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/ : RegExp +> : ^^^^^^ + +// U+102A7 CARIAN LETTER A2: character outside BMP with both ID_Start and ID_Continue +/(?<𐊧>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/; +>/(?<𐊧>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/ : RegExp +> : ^^^^^^ + +/(?<\u{102A7}>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/; +>/(?<\u{102A7}>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/ : RegExp +> : ^^^^^^ + +/(?<\uD800\uDEA7>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/; +>/(?<\uD800\uDEA7>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/ : RegExp +> : ^^^^^^ + +/(?<_𐊧>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/; +>/(?<_𐊧>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/ : RegExp +> : ^^^^^^ + +/(?<_\u{102A7}>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/; +>/(?<_\u{102A7}>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/ : RegExp +> : ^^^^^^ + +/(?<_\uD800\uDEA7>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/; +>/(?<_\uD800\uDEA7>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/ : RegExp +> : ^^^^^^ + +// U+1113D CHAKMA DIGIT SEVEN: character outside BMP with only ID_Continue +/(?<π‘„½>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/; // invalid +>/(?<π‘„½>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/ : RegExp +> : ^^^^^^ + +/(?<\u{1113D}>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/; // invalid +>/(?<\u{1113D}>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/ : RegExp +> : ^^^^^^ + +/(?<\uD804\uDD3D>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/; // invalid +>/(?<\uD804\uDD3D>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/ : RegExp +> : ^^^^^^ + +/(?<_π‘„½>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/; +>/(?<_π‘„½>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/ : RegExp +> : ^^^^^^ + +/(?<_\u{1113D}>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/; +>/(?<_\u{1113D}>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/ : RegExp +> : ^^^^^^ + +/(?<_\uD804\uDD3D>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/; +>/(?<_\uD804\uDD3D>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/ : RegExp +> : ^^^^^^ + +// The following cases are all invalid: + +// U+2F47 KANGXI RADICAL SUN: character inside BMP without both properties +/(?<⽇>)(?<\u2F47>)(?<\u{2F47}>)\k<⽇>\k<\u2F47>\k<\u{2F47}>/; +>/(?<⽇>)(?<\u2F47>)(?<\u{2F47}>)\k<⽇>\k<\u2F47>\k<\u{2F47}>/ : RegExp +> : ^^^^^^ + +/(?<_⽇>)(?<_\u2F47>)(?<_\u{2F47}>)\k<_⽇>\k<_\u2F47>\k<_\u{2F47}>/; +>/(?<_⽇>)(?<_\u2F47>)(?<_\u{2F47}>)\k<_⽇>\k<_\u2F47>\k<_\u{2F47}>/ : RegExp +> : ^^^^^^ + +// U+1F31A NEW MOON WITH FACE: character outside BMP without both properties +/(?<🌚>)(?<\u{1F31A}>)(?<\uD83C\uDF1A>)\k<🌚>\k<\u{1F31A}>\k<\uD83C\uDF1A>/; +>/(?<🌚>)(?<\u{1F31A}>)(?<\uD83C\uDF1A>)\k<🌚>\k<\u{1F31A}>\k<\uD83C\uDF1A>/ : RegExp +> : ^^^^^^ + +/(?<_🌚>)(?<_\u{1F31A}>)(?<_\uD83C\uDF1A>)\k<_🌚>\k<_\u{1F31A}>\k<_\uD83C\uDF1A>/; +>/(?<_🌚>)(?<_\u{1F31A}>)(?<_\uD83C\uDF1A>)\k<_🌚>\k<_\u{1F31A}>\k<_\uD83C\uDF1A>/ : RegExp +> : ^^^^^^ + +// Lone leading surrogate +/(?<\uD800>)(?<\u{D800}>)\k<\uD800>\k<\u{D800}>/; +>/(?<\uD800>)(?<\u{D800}>)\k<\uD800>\k<\u{D800}>/ : RegExp +> : ^^^^^^ + +/(?<_\uD800>)(?<_\u{D800}>)\k<_\uD800>\k<_\u{D800}>/; +>/(?<_\uD800>)(?<_\u{D800}>)\k<_\uD800>\k<_\u{D800}>/ : RegExp +> : ^^^^^^ + +// Lone trailing surrogate +/(?<\uDFFF>)(?<\u{DFFF}>)\k<\uDFFF>\k<\u{DFFF}>/; +>/(?<\uDFFF>)(?<\u{DFFF}>)\k<\uDFFF>\k<\u{DFFF}>/ : RegExp +> : ^^^^^^ + +/(?<_\uDFFF>)(?<_\u{DFFF}>)\k<_\uDFFF>\k<_\u{DFFF}>/; +>/(?<_\uDFFF>)(?<_\u{DFFF}>)\k<_\uDFFF>\k<_\u{DFFF}>/ : RegExp +> : ^^^^^^ + +// Fake surrogate pair with extended Unicode escapes – invalid even if the intended character has both properties +/(?<\u{D800}\u{DC00}>)\k<\u{D800}\u{DC00}>/; +>/(?<\u{D800}\u{DC00}>)\k<\u{D800}\u{DC00}>/ : RegExp +> : ^^^^^^ + +/(?<_\u{D800}\u{DC00}>)\k<_\u{D800}\u{DC00}>/; +>/(?<_\u{D800}\u{DC00}>)\k<_\u{D800}\u{DC00}>/ : RegExp +> : ^^^^^^ + +// Cases with Unicode escapes and extended Unicode escapes mixed +/(?)\k\k<\u{52}\u0065gE\u{78}p>\k<\u0052e\u0067\u{45}x\u{70}>/; +>/(?)\k\k<\u{52}\u0065gE\u{78}p>\k<\u0052e\u0067\u{45}x\u{70}>/ : RegExp +> : ^^^^^^ + +/(?<_RegExp>)\k<_RegExp>\k<_\u{52}\u0065gE\u{78}p>\k<_\u0052e\u0067\u{45}x\u{70}>/; +>/(?<_RegExp>)\k<_RegExp>\k<_\u{52}\u0065gE\u{78}p>\k<_\u0052e\u0067\u{45}x\u{70}>/ : RegExp +> : ^^^^^^ + diff --git a/tests/cases/compiler/regularExpressionGroupNameUnicodeEscapes.ts b/tests/cases/compiler/regularExpressionGroupNameUnicodeEscapes.ts new file mode 100644 index 0000000000000..66c9d9f922dda --- /dev/null +++ b/tests/cases/compiler/regularExpressionGroupNameUnicodeEscapes.ts @@ -0,0 +1,63 @@ +// @target: esnext + +// U+13A0 CHEROKEE LETTER A: character inside BMP with both the Unicode properties ID_Start and ID_Continue +/(?<Ꭰ>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/; +/(?<\u13A0>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/; +/(?<\u{13A0}>)\k<Ꭰ>\k<\u13A0>\k<\u{13A0}>/; + +/(?<_Ꭰ>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/; +/(?<_\u13A0>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/; +/(?<_\u{13A0}>)\k<_Ꭰ>\k<_\u13A0>\k<_\u{13A0}>/; + +// U+19D4 NEW TAI LUE DIGIT FOUR: character inside BMP with only ID_Continue +/(?<α§”>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/; // invalid +/(?<\u19D4>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/; // invalid +/(?<\u{19D4}>)\k<α§”>\k<\u19D4>\k<\u{19D4}>/; // invalid + +/(?<_α§”>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/; +/(?<_\u19D4>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/; +/(?<_\u{19D4}>)\k<_α§”>\k<_\u19D4>\k<_\u{19D4}>/; + +// U+102A7 CARIAN LETTER A2: character outside BMP with both ID_Start and ID_Continue +/(?<𐊧>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/; +/(?<\u{102A7}>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/; +/(?<\uD800\uDEA7>)\k<𐊧>\k<\u{102A7}>\k<\uD800\uDEA7>/; + +/(?<_𐊧>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/; +/(?<_\u{102A7}>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/; +/(?<_\uD800\uDEA7>)\k<_𐊧>\k<_\u{102A7}>\k<_\uD800\uDEA7>/; + +// U+1113D CHAKMA DIGIT SEVEN: character outside BMP with only ID_Continue +/(?<π‘„½>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/; // invalid +/(?<\u{1113D}>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/; // invalid +/(?<\uD804\uDD3D>)\k<π‘„½>\k<\u{1113D}>\k<\uD804\uDD3D>/; // invalid + +/(?<_π‘„½>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/; +/(?<_\u{1113D}>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/; +/(?<_\uD804\uDD3D>)\k<_π‘„½>\k<_\u{1113D}>\k<_\uD804\uDD3D>/; + +// The following cases are all invalid: + +// U+2F47 KANGXI RADICAL SUN: character inside BMP without both properties +/(?<⽇>)(?<\u2F47>)(?<\u{2F47}>)\k<⽇>\k<\u2F47>\k<\u{2F47}>/; +/(?<_⽇>)(?<_\u2F47>)(?<_\u{2F47}>)\k<_⽇>\k<_\u2F47>\k<_\u{2F47}>/; + +// U+1F31A NEW MOON WITH FACE: character outside BMP without both properties +/(?<🌚>)(?<\u{1F31A}>)(?<\uD83C\uDF1A>)\k<🌚>\k<\u{1F31A}>\k<\uD83C\uDF1A>/; +/(?<_🌚>)(?<_\u{1F31A}>)(?<_\uD83C\uDF1A>)\k<_🌚>\k<_\u{1F31A}>\k<_\uD83C\uDF1A>/; + +// Lone leading surrogate +/(?<\uD800>)(?<\u{D800}>)\k<\uD800>\k<\u{D800}>/; +/(?<_\uD800>)(?<_\u{D800}>)\k<_\uD800>\k<_\u{D800}>/; + +// Lone trailing surrogate +/(?<\uDFFF>)(?<\u{DFFF}>)\k<\uDFFF>\k<\u{DFFF}>/; +/(?<_\uDFFF>)(?<_\u{DFFF}>)\k<_\uDFFF>\k<_\u{DFFF}>/; + +// Fake surrogate pair with extended Unicode escapes – invalid even if the intended character has both properties +/(?<\u{D800}\u{DC00}>)\k<\u{D800}\u{DC00}>/; +/(?<_\u{D800}\u{DC00}>)\k<_\u{D800}\u{DC00}>/; + +// Cases with Unicode escapes and extended Unicode escapes mixed +/(?)\k\k<\u{52}\u0065gE\u{78}p>\k<\u0052e\u0067\u{45}x\u{70}>/; +/(?<_RegExp>)\k<_RegExp>\k<_\u{52}\u0065gE\u{78}p>\k<_\u0052e\u0067\u{45}x\u{70}>/; From d7e371fbd61352bb23441d6f9a7f6fff3beb24e8 Mon Sep 17 00:00:00 2001 From: graphemecluster Date: Thu, 23 Jan 2025 19:20:59 +0800 Subject: [PATCH 3/4] Add test cases for identifiers with text in-between Unicode escapes --- ...xtendedUnicodeEscapeSequenceIdentifiers.js | 6 +- ...edUnicodeEscapeSequenceIdentifiers.symbols | 6 +- ...ndedUnicodeEscapeSequenceIdentifiers.types | 16 +- .../reference/unicodeEscapesInJSDoc.js | 20 +- .../reference/unicodeEscapesInJSDoc.symbols | 32 +- .../reference/unicodeEscapesInJSDoc.types | 38 +- .../unicodeEscapesInJsxtags.errors.txt | 38 +- .../reference/unicodeEscapesInJsxtags.js | 10 + .../reference/unicodeEscapesInJsxtags.symbols | 50 +- .../reference/unicodeEscapesInJsxtags.types | 56 + .../unicodeEscapesInNames01(target=es2015).js | 128 +- ...codeEscapesInNames01(target=es2015).js.map | 24 + ...apesInNames01(target=es2015).sourcemap.txt | 616 +++++++++- ...odeEscapesInNames01(target=es2015).symbols | 106 ++ ...icodeEscapesInNames01(target=es2015).types | 182 +++ ...odeEscapesInNames01(target=es5).errors.txt | 66 ++ .../unicodeEscapesInNames01(target=es5).js | 154 ++- ...unicodeEscapesInNames01(target=es5).js.map | 24 + ...EscapesInNames01(target=es5).sourcemap.txt | 744 +++++++++++- ...nicodeEscapesInNames01(target=es5).symbols | 106 ++ .../unicodeEscapesInNames01(target=es5).types | 182 +++ .../unicodeEscapesInNames01(target=esnext).js | 114 +- ...codeEscapesInNames01(target=esnext).js.map | 24 + ...apesInNames01(target=esnext).sourcemap.txt | 622 +++++++++- ...odeEscapesInNames01(target=esnext).symbols | 106 ++ ...icodeEscapesInNames01(target=esnext).types | 182 +++ .../unicodeEscapesInNames03(target=es2015).js | 159 +++ ...codeEscapesInNames03(target=es2015).js.map | 71 ++ ...apesInNames03(target=es2015).sourcemap.txt | 1037 +++++++++++++++++ ...odeEscapesInNames03(target=es2015).symbols | 192 +++ ...icodeEscapesInNames03(target=es2015).types | 336 ++++++ .../unicodeEscapesInNames03(target=es5).js | 201 ++++ ...unicodeEscapesInNames03(target=es5).js.map | 71 ++ ...EscapesInNames03(target=es5).sourcemap.txt | 988 ++++++++++++++++ ...nicodeEscapesInNames03(target=es5).symbols | 192 +++ .../unicodeEscapesInNames03(target=es5).types | 336 ++++++ .../unicodeEscapesInNames03(target=esnext).js | 159 +++ ...codeEscapesInNames03(target=esnext).js.map | 71 ++ ...apesInNames03(target=esnext).sourcemap.txt | 1037 +++++++++++++++++ ...odeEscapesInNames03(target=esnext).symbols | 192 +++ ...icodeEscapesInNames03(target=esnext).types | 336 ++++++ ...xtendedUnicodeEscapeSequenceIdentifiers.ts | 3 +- tests/cases/compiler/unicodeEscapesInJSDoc.ts | 10 +- .../cases/compiler/unicodeEscapesInNames01.ts | 60 + .../cases/compiler/unicodeEscapesInNames03.ts | 86 ++ .../jsx/unicodeEscapesInJsxtags.tsx | 6 + 46 files changed, 9123 insertions(+), 72 deletions(-) create mode 100644 tests/baselines/reference/unicodeEscapesInNames03(target=es2015).js create mode 100644 tests/baselines/reference/unicodeEscapesInNames03(target=es2015).js.map create mode 100644 tests/baselines/reference/unicodeEscapesInNames03(target=es2015).sourcemap.txt create mode 100644 tests/baselines/reference/unicodeEscapesInNames03(target=es2015).symbols create mode 100644 tests/baselines/reference/unicodeEscapesInNames03(target=es2015).types create mode 100644 tests/baselines/reference/unicodeEscapesInNames03(target=es5).js create mode 100644 tests/baselines/reference/unicodeEscapesInNames03(target=es5).js.map create mode 100644 tests/baselines/reference/unicodeEscapesInNames03(target=es5).sourcemap.txt create mode 100644 tests/baselines/reference/unicodeEscapesInNames03(target=es5).symbols create mode 100644 tests/baselines/reference/unicodeEscapesInNames03(target=es5).types create mode 100644 tests/baselines/reference/unicodeEscapesInNames03(target=esnext).js create mode 100644 tests/baselines/reference/unicodeEscapesInNames03(target=esnext).js.map create mode 100644 tests/baselines/reference/unicodeEscapesInNames03(target=esnext).sourcemap.txt create mode 100644 tests/baselines/reference/unicodeEscapesInNames03(target=esnext).symbols create mode 100644 tests/baselines/reference/unicodeEscapesInNames03(target=esnext).types create mode 100644 tests/cases/compiler/unicodeEscapesInNames03.ts diff --git a/tests/baselines/reference/extendedUnicodeEscapeSequenceIdentifiers.js b/tests/baselines/reference/extendedUnicodeEscapeSequenceIdentifiers.js index 4072ce2a3ab56..384839dafc36c 100644 --- a/tests/baselines/reference/extendedUnicodeEscapeSequenceIdentifiers.js +++ b/tests/baselines/reference/extendedUnicodeEscapeSequenceIdentifiers.js @@ -3,11 +3,13 @@ //// [extendedUnicodeEscapeSequenceIdentifiers.ts] const \u{0061} = 12; const a\u{0061} = 12; +const a\u{62}c\u{64}e = 12; -console.log(a + aa); +console.log(a + aa + abcde); //// [extendedUnicodeEscapeSequenceIdentifiers.js] const \u{0061} = 12; const a\u{0061} = 12; -console.log(a + aa); +const a\u{62}c\u{64}e = 12; +console.log(a + aa + abcde); diff --git a/tests/baselines/reference/extendedUnicodeEscapeSequenceIdentifiers.symbols b/tests/baselines/reference/extendedUnicodeEscapeSequenceIdentifiers.symbols index 3cc06929eefa2..23d0ac0b5fdd7 100644 --- a/tests/baselines/reference/extendedUnicodeEscapeSequenceIdentifiers.symbols +++ b/tests/baselines/reference/extendedUnicodeEscapeSequenceIdentifiers.symbols @@ -7,10 +7,14 @@ const \u{0061} = 12; const a\u{0061} = 12; >a\u{0061} : Symbol(a\u{0061}, Decl(extendedUnicodeEscapeSequenceIdentifiers.ts, 1, 5)) -console.log(a + aa); +const a\u{62}c\u{64}e = 12; +>a\u{62}c\u{64}e : Symbol(a\u{62}c\u{64}e, Decl(extendedUnicodeEscapeSequenceIdentifiers.ts, 2, 5)) + +console.log(a + aa + abcde); >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) >log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) >a : Symbol(\u{0061}, Decl(extendedUnicodeEscapeSequenceIdentifiers.ts, 0, 5)) >aa : Symbol(a\u{0061}, Decl(extendedUnicodeEscapeSequenceIdentifiers.ts, 1, 5)) +>abcde : Symbol(a\u{62}c\u{64}e, Decl(extendedUnicodeEscapeSequenceIdentifiers.ts, 2, 5)) diff --git a/tests/baselines/reference/extendedUnicodeEscapeSequenceIdentifiers.types b/tests/baselines/reference/extendedUnicodeEscapeSequenceIdentifiers.types index cbd29c418f4fe..83a5311bc5fd5 100644 --- a/tests/baselines/reference/extendedUnicodeEscapeSequenceIdentifiers.types +++ b/tests/baselines/reference/extendedUnicodeEscapeSequenceIdentifiers.types @@ -13,19 +13,29 @@ const a\u{0061} = 12; >12 : 12 > : ^^ -console.log(a + aa); ->console.log(a + aa) : void -> : ^^^^ +const a\u{62}c\u{64}e = 12; +>a\u{62}c\u{64}e : 12 +> : ^^ +>12 : 12 +> : ^^ + +console.log(a + aa + abcde); +>console.log(a + aa + abcde) : void +> : ^^^^ >console.log : (...data: any[]) => void > : ^^^^ ^^ ^^^^^ >console : Console > : ^^^^^^^ >log : (...data: any[]) => void > : ^^^^ ^^ ^^^^^ +>a + aa + abcde : number +> : ^^^^^^ >a + aa : number > : ^^^^^^ >a : 12 > : ^^ >aa : 12 > : ^^ +>abcde : 12 +> : ^^ diff --git a/tests/baselines/reference/unicodeEscapesInJSDoc.js b/tests/baselines/reference/unicodeEscapesInJSDoc.js index 76aca7f81862c..d90a066c630c2 100644 --- a/tests/baselines/reference/unicodeEscapesInJSDoc.js +++ b/tests/baselines/reference/unicodeEscapesInJSDoc.js @@ -4,17 +4,19 @@ /** * @param {number} \u0061 * @param {number} a\u0061 + * @param {number} a\u0062c\u0064e */ -function foo(a, aa) { - console.log(a + aa); +function foo(a, aa, abcde) { + console.log(a + aa + abcde); } /** * @param {number} \u{0061} * @param {number} a\u{0061} + * @param {number} a\u{62}c\u{64}e */ -function bar(a, aa) { - console.log(a + aa); +function bar(a, aa, abcde) { + console.log(a + aa + abcde); } @@ -22,14 +24,16 @@ function bar(a, aa) { /** * @param {number} \u0061 * @param {number} a\u0061 + * @param {number} a\u0062c\u0064e */ -function foo(a, aa) { - console.log(a + aa); +function foo(a, aa, abcde) { + console.log(a + aa + abcde); } /** * @param {number} \u{0061} * @param {number} a\u{0061} + * @param {number} a\u{62}c\u{64}e */ -function bar(a, aa) { - console.log(a + aa); +function bar(a, aa, abcde) { + console.log(a + aa + abcde); } diff --git a/tests/baselines/reference/unicodeEscapesInJSDoc.symbols b/tests/baselines/reference/unicodeEscapesInJSDoc.symbols index 2ef9a193c705e..bdc7065af073b 100644 --- a/tests/baselines/reference/unicodeEscapesInJSDoc.symbols +++ b/tests/baselines/reference/unicodeEscapesInJSDoc.symbols @@ -4,34 +4,40 @@ /** * @param {number} \u0061 * @param {number} a\u0061 + * @param {number} a\u0062c\u0064e */ -function foo(a, aa) { +function foo(a, aa, abcde) { >foo : Symbol(foo, Decl(file.js, 0, 0)) ->a : Symbol(a, Decl(file.js, 4, 13)) ->aa : Symbol(aa, Decl(file.js, 4, 15)) +>a : Symbol(a, Decl(file.js, 5, 13)) +>aa : Symbol(aa, Decl(file.js, 5, 15)) +>abcde : Symbol(abcde, Decl(file.js, 5, 19)) - console.log(a + aa); + console.log(a + aa + abcde); >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) >log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->a : Symbol(a, Decl(file.js, 4, 13)) ->aa : Symbol(aa, Decl(file.js, 4, 15)) +>a : Symbol(a, Decl(file.js, 5, 13)) +>aa : Symbol(aa, Decl(file.js, 5, 15)) +>abcde : Symbol(abcde, Decl(file.js, 5, 19)) } /** * @param {number} \u{0061} * @param {number} a\u{0061} + * @param {number} a\u{62}c\u{64}e */ -function bar(a, aa) { ->bar : Symbol(bar, Decl(file.js, 6, 1)) ->a : Symbol(a, Decl(file.js, 12, 13)) ->aa : Symbol(aa, Decl(file.js, 12, 15)) +function bar(a, aa, abcde) { +>bar : Symbol(bar, Decl(file.js, 7, 1)) +>a : Symbol(a, Decl(file.js, 14, 13)) +>aa : Symbol(aa, Decl(file.js, 14, 15)) +>abcde : Symbol(abcde, Decl(file.js, 14, 19)) - console.log(a + aa); + console.log(a + aa + abcde); >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) >log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->a : Symbol(a, Decl(file.js, 12, 13)) ->aa : Symbol(aa, Decl(file.js, 12, 15)) +>a : Symbol(a, Decl(file.js, 14, 13)) +>aa : Symbol(aa, Decl(file.js, 14, 15)) +>abcde : Symbol(abcde, Decl(file.js, 14, 19)) } diff --git a/tests/baselines/reference/unicodeEscapesInJSDoc.types b/tests/baselines/reference/unicodeEscapesInJSDoc.types index cbaaa47609eff..68c1f1ee236e8 100644 --- a/tests/baselines/reference/unicodeEscapesInJSDoc.types +++ b/tests/baselines/reference/unicodeEscapesInJSDoc.types @@ -4,58 +4,72 @@ /** * @param {number} \u0061 * @param {number} a\u0061 + * @param {number} a\u0062c\u0064e */ -function foo(a, aa) { ->foo : (a: number, aa: number) => void -> : ^ ^^ ^^ ^^ ^^^^^^^^^ +function foo(a, aa, abcde) { +>foo : (a: number, aa: number, abcde: number) => void +> : ^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^^^ >a : number > : ^^^^^^ >aa : number > : ^^^^^^ +>abcde : number +> : ^^^^^^ - console.log(a + aa); ->console.log(a + aa) : void -> : ^^^^ + console.log(a + aa + abcde); +>console.log(a + aa + abcde) : void +> : ^^^^ >console.log : (...data: any[]) => void > : ^^^^ ^^ ^^^^^ >console : Console > : ^^^^^^^ >log : (...data: any[]) => void > : ^^^^ ^^ ^^^^^ +>a + aa + abcde : number +> : ^^^^^^ >a + aa : number > : ^^^^^^ >a : number > : ^^^^^^ >aa : number > : ^^^^^^ +>abcde : number +> : ^^^^^^ } /** * @param {number} \u{0061} * @param {number} a\u{0061} + * @param {number} a\u{62}c\u{64}e */ -function bar(a, aa) { ->bar : (a: number, aa: number) => void -> : ^ ^^ ^^ ^^ ^^^^^^^^^ +function bar(a, aa, abcde) { +>bar : (a: number, aa: number, abcde: number) => void +> : ^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^^^ >a : number > : ^^^^^^ >aa : number > : ^^^^^^ +>abcde : number +> : ^^^^^^ - console.log(a + aa); ->console.log(a + aa) : void -> : ^^^^ + console.log(a + aa + abcde); +>console.log(a + aa + abcde) : void +> : ^^^^ >console.log : (...data: any[]) => void > : ^^^^ ^^ ^^^^^ >console : Console > : ^^^^^^^ >log : (...data: any[]) => void > : ^^^^ ^^ ^^^^^ +>a + aa + abcde : number +> : ^^^^^^ >a + aa : number > : ^^^^^^ >a : number > : ^^^^^^ >aa : number > : ^^^^^^ +>abcde : number +> : ^^^^^^ } diff --git a/tests/baselines/reference/unicodeEscapesInJsxtags.errors.txt b/tests/baselines/reference/unicodeEscapesInJsxtags.errors.txt index cc664d0d2ece4..a585e1244c59a 100644 --- a/tests/baselines/reference/unicodeEscapesInJsxtags.errors.txt +++ b/tests/baselines/reference/unicodeEscapesInJsxtags.errors.txt @@ -1,23 +1,31 @@ -file.tsx(15,4): error TS17021: Unicode escape sequence cannot appear here. -file.tsx(16,4): error TS17021: Unicode escape sequence cannot appear here. file.tsx(17,4): error TS17021: Unicode escape sequence cannot appear here. file.tsx(18,4): error TS17021: Unicode escape sequence cannot appear here. -file.tsx(19,6): error TS17021: Unicode escape sequence cannot appear here. +file.tsx(19,4): error TS17021: Unicode escape sequence cannot appear here. file.tsx(20,4): error TS17021: Unicode escape sequence cannot appear here. -file.tsx(21,4): error TS17021: Unicode escape sequence cannot appear here. +file.tsx(21,6): error TS17021: Unicode escape sequence cannot appear here. file.tsx(22,4): error TS17021: Unicode escape sequence cannot appear here. file.tsx(23,4): error TS17021: Unicode escape sequence cannot appear here. -file.tsx(26,9): error TS17021: Unicode escape sequence cannot appear here. -file.tsx(27,9): error TS17021: Unicode escape sequence cannot appear here. +file.tsx(24,4): error TS17021: Unicode escape sequence cannot appear here. +file.tsx(25,4): error TS17021: Unicode escape sequence cannot appear here. +file.tsx(26,4): error TS17021: Unicode escape sequence cannot appear here. +file.tsx(26,20): error TS17021: Unicode escape sequence cannot appear here. +file.tsx(27,4): error TS17021: Unicode escape sequence cannot appear here. +file.tsx(27,44): error TS17021: Unicode escape sequence cannot appear here. +file.tsx(30,9): error TS17021: Unicode escape sequence cannot appear here. +file.tsx(31,9): error TS17021: Unicode escape sequence cannot appear here. +file.tsx(32,9): error TS17021: Unicode escape sequence cannot appear here. +file.tsx(33,9): error TS17021: Unicode escape sequence cannot appear here. -==== file.tsx (11 errors) ==== +==== file.tsx (17 errors) ==== import * as React from "react"; declare global { namespace JSX { interface IntrinsicElements { "a-b": any; "a-c": any; + "abcde:abcde": any; + "namespace-name:tagname-tag": any; } } } @@ -53,6 +61,16 @@ file.tsx(27,9): error TS17021: Unicode escape sequence cannot appear here. ; ~~~~~~~~~~~~ !!! error TS17021: Unicode escape sequence cannot appear here. + ; + ~~~~~~~~~~~~~~~ +!!! error TS17021: Unicode escape sequence cannot appear here. + ~~~~~~~~~~~~~~~ +!!! error TS17021: Unicode escape sequence cannot appear here. + ; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS17021: Unicode escape sequence cannot appear here. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS17021: Unicode escape sequence cannot appear here. // attribute name ;