Skip to content

Commit 36c3bb3

Browse files
committed
fix again
1 parent c4cb21d commit 36c3bb3

6 files changed

+62
-10
lines changed

src/compiler/parser.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,10 +1116,6 @@ namespace ts {
11161116
}
11171117

11181118
function reScanTemplateHeadOrNoSubstitutionTemplate(): SyntaxKind {
1119-
let lastError: DiagnosticWithLocation | undefined;
1120-
while ((lastError = lastOrUndefined(parseDiagnostics)) && scanner.getTokenPos() < lastError.start) {
1121-
parseDiagnostics.pop();
1122-
}
11231119
return currentToken = scanner.reScanTemplateHeadOrNoSubstitutionTemplate();
11241120
}
11251121

src/compiler/scanner.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,8 +1288,10 @@ namespace ts {
12881288
return text.substring(start, pos);
12891289
}
12901290

1291-
const escapedValue = peekExtendedUnicodeEscape();
12921291
if (isTaggedTemplate) {
1292+
const escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false);
1293+
const escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
1294+
12931295
// '\u{Not Code Point' or '\u{CodePoint'
12941296
if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== CharacterCodes.closeBrace) {
12951297
tokenFlags |= TokenFlags.ContainsInvalidEscape;

tests/baselines/reference/invalidTaggedTemplateEscapeSequences.errors.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1+
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences.ts(7,18): error TS1125: Hexadecimal digit expected.
12
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences.ts(8,15): error TS1125: Hexadecimal digit expected.
23
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences.ts(8,33): error TS1125: Hexadecimal digit expected.
34
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences.ts(8,75): error TS1125: Hexadecimal digit expected.
5+
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences.ts(9,18): error TS1125: Hexadecimal digit expected.
6+
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences.ts(9,27): error TS1125: Hexadecimal digit expected.
7+
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences.ts(9,51): error TS1125: Hexadecimal digit expected.
8+
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences.ts(19,33): error TS1125: Hexadecimal digit expected.
9+
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences.ts(21,33): error TS1125: Hexadecimal digit expected.
410

511

6-
==== tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences.ts (3 errors) ====
12+
==== tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences.ts (9 errors) ====
713
function tag (str: any, ...args: any[]): any {
814
return str
915
}
1016

1117
const a = tag`123`
1218
const b = tag`123 ${100}`
1319
const x = tag`\u{hello} ${ 100 } \xtraordinary ${ 200 } wonderful ${ 300 } \uworld`;
20+
21+
!!! error TS1125: Hexadecimal digit expected.
1422
const y = `\u{hello} ${ 100 } \xtraordinary ${ 200 } wonderful ${ 300 } \uworld`; // should error with NoSubstitutionTemplate
1523

1624
!!! error TS1125: Hexadecimal digit expected.
@@ -19,6 +27,12 @@ tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences.ts(8,75): er
1927

2028
!!! error TS1125: Hexadecimal digit expected.
2129
const z = tag`\u{hello} \xtraordinary wonderful \uworld` // should work with Tagged NoSubstitutionTemplate
30+
31+
!!! error TS1125: Hexadecimal digit expected.
32+
33+
!!! error TS1125: Hexadecimal digit expected.
34+
35+
!!! error TS1125: Hexadecimal digit expected.
2236

2337
const a1 = tag`${ 100 }\0` // \0
2438
const a2 = tag`${ 100 }\00` // \\00
@@ -29,8 +43,12 @@ tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences.ts(8,75): er
2943
const a7 = tag`${ 100 }\u0000` // \u0000
3044
const a8 = tag`${ 100 }\u{` // \\u{
3145
const a9 = tag`${ 100 }\u{10FFFF}` // \\u{10FFFF
46+
47+
!!! error TS1125: Hexadecimal digit expected.
3248
const a10 = tag`${ 100 }\u{1f622` // \\u{1f622
3349
const a11 = tag`${ 100 }\u{1f622}` // \u{1f622}
50+
51+
!!! error TS1125: Hexadecimal digit expected.
3452
const a12 = tag`${ 100 }\x` // \\x
3553
const a13 = tag`${ 100 }\x0` // \\x0
3654
const a14 = tag`${ 100 }\x00` // \x00

tests/baselines/reference/invalidTaggedTemplateEscapeSequences.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ var a5 = tag(__makeTemplateObject(["", undefined], ["", "\\u00"]), 100); // \\u0
5050
var a6 = tag(__makeTemplateObject(["", undefined], ["", "\\u000"]), 100); // \\u000
5151
var a7 = tag(__makeTemplateObject(["", "\0"], ["", "\\u0000"]), 100); // \u0000
5252
var a8 = tag(__makeTemplateObject(["", undefined], ["", "\\u{"]), 100); // \\u{
53-
var a9 = tag(__makeTemplateObject(["", "\uDBFF\uDFFF"], ["", "\\u{10FFFF}"]), 100); // \\u{10FFFF
53+
var a9 = tag(__makeTemplateObject(["", ""], ["", "\\u{10FFFF}"]), 100); // \\u{10FFFF
5454
var a10 = tag(__makeTemplateObject(["", undefined], ["", "\\u{1f622"]), 100); // \\u{1f622
55-
var a11 = tag(__makeTemplateObject(["", "\uD83D\uDE22"], ["", "\\u{1f622}"]), 100); // \u{1f622}
55+
var a11 = tag(__makeTemplateObject(["", ""], ["", "\\u{1f622}"]), 100); // \u{1f622}
5656
var a12 = tag(__makeTemplateObject(["", undefined], ["", "\\x"]), 100); // \\x
5757
var a13 = tag(__makeTemplateObject(["", undefined], ["", "\\x0"]), 100); // \\x0
5858
var a14 = tag(__makeTemplateObject(["", "\0"], ["", "\\x00"]), 100); // \x00

tests/baselines/reference/invalidTaggedTemplateEscapeSequences_es2015.errors.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1+
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_es2015.ts(7,18): error TS1125: Hexadecimal digit expected.
12
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_es2015.ts(8,15): error TS1125: Hexadecimal digit expected.
23
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_es2015.ts(8,33): error TS1125: Hexadecimal digit expected.
34
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_es2015.ts(8,75): error TS1125: Hexadecimal digit expected.
5+
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_es2015.ts(9,18): error TS1125: Hexadecimal digit expected.
6+
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_es2015.ts(9,27): error TS1125: Hexadecimal digit expected.
7+
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_es2015.ts(9,51): error TS1125: Hexadecimal digit expected.
8+
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_es2015.ts(19,33): error TS1125: Hexadecimal digit expected.
9+
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_es2015.ts(21,33): error TS1125: Hexadecimal digit expected.
410

511

6-
==== tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_es2015.ts (3 errors) ====
12+
==== tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_es2015.ts (9 errors) ====
713
function tag (str: any, ...args: any[]): any {
814
return str
915
}
1016

1117
const a = tag`123`
1218
const b = tag`123 ${100}`
1319
const x = tag`\u{hello} ${ 100 } \xtraordinary ${ 200 } wonderful ${ 300 } \uworld`;
20+
21+
!!! error TS1125: Hexadecimal digit expected.
1422
const y = `\u{hello} ${ 100 } \xtraordinary ${ 200 } wonderful ${ 300 } \uworld`; // should error with NoSubstitutionTemplate
1523

1624
!!! error TS1125: Hexadecimal digit expected.
@@ -19,6 +27,12 @@ tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_es2015.ts(8,
1927

2028
!!! error TS1125: Hexadecimal digit expected.
2129
const z = tag`\u{hello} \xtraordinary wonderful \uworld` // should work with Tagged NoSubstitutionTemplate
30+
31+
!!! error TS1125: Hexadecimal digit expected.
32+
33+
!!! error TS1125: Hexadecimal digit expected.
34+
35+
!!! error TS1125: Hexadecimal digit expected.
2236

2337
const a1 = tag`${ 100 }\0` // \0
2438
const a2 = tag`${ 100 }\00` // \\00
@@ -29,8 +43,12 @@ tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_es2015.ts(8,
2943
const a7 = tag`${ 100 }\u0000` // \u0000
3044
const a8 = tag`${ 100 }\u{` // \\u{
3145
const a9 = tag`${ 100 }\u{10FFFF}` // \\u{10FFFF
46+
47+
!!! error TS1125: Hexadecimal digit expected.
3248
const a10 = tag`${ 100 }\u{1f622` // \\u{1f622
3349
const a11 = tag`${ 100 }\u{1f622}` // \u{1f622}
50+
51+
!!! error TS1125: Hexadecimal digit expected.
3452
const a12 = tag`${ 100 }\x` // \\x
3553
const a13 = tag`${ 100 }\x0` // \\x0
3654
const a14 = tag`${ 100 }\x00` // \x00

tests/baselines/reference/invalidTaggedTemplateEscapeSequences_esnext.errors.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1+
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_esnext.ts(7,18): error TS1125: Hexadecimal digit expected.
12
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_esnext.ts(8,15): error TS1125: Hexadecimal digit expected.
23
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_esnext.ts(8,33): error TS1125: Hexadecimal digit expected.
34
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_esnext.ts(8,75): error TS1125: Hexadecimal digit expected.
5+
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_esnext.ts(9,18): error TS1125: Hexadecimal digit expected.
6+
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_esnext.ts(9,27): error TS1125: Hexadecimal digit expected.
7+
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_esnext.ts(9,51): error TS1125: Hexadecimal digit expected.
8+
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_esnext.ts(19,33): error TS1125: Hexadecimal digit expected.
9+
tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_esnext.ts(21,33): error TS1125: Hexadecimal digit expected.
410

511

6-
==== tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_esnext.ts (3 errors) ====
12+
==== tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_esnext.ts (9 errors) ====
713
function tag (str: any, ...args: any[]): any {
814
return str
915
}
1016

1117
const a = tag`123`
1218
const b = tag`123 ${100}`
1319
const x = tag`\u{hello} ${ 100 } \xtraordinary ${ 200 } wonderful ${ 300 } \uworld`;
20+
21+
!!! error TS1125: Hexadecimal digit expected.
1422
const y = `\u{hello} ${ 100 } \xtraordinary ${ 200 } wonderful ${ 300 } \uworld`; // should error with NoSubstitutionTemplate
1523

1624
!!! error TS1125: Hexadecimal digit expected.
@@ -19,6 +27,12 @@ tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_esnext.ts(8,
1927

2028
!!! error TS1125: Hexadecimal digit expected.
2129
const z = tag`\u{hello} \xtraordinary wonderful \uworld` // should work with Tagged NoSubstitutionTemplate
30+
31+
!!! error TS1125: Hexadecimal digit expected.
32+
33+
!!! error TS1125: Hexadecimal digit expected.
34+
35+
!!! error TS1125: Hexadecimal digit expected.
2236

2337
const a1 = tag`${ 100 }\0` // \0
2438
const a2 = tag`${ 100 }\00` // \\00
@@ -29,8 +43,12 @@ tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences_esnext.ts(8,
2943
const a7 = tag`${ 100 }\u0000` // \u0000
3044
const a8 = tag`${ 100 }\u{` // \\u{
3145
const a9 = tag`${ 100 }\u{10FFFF}` // \\u{10FFFF
46+
47+
!!! error TS1125: Hexadecimal digit expected.
3248
const a10 = tag`${ 100 }\u{1f622` // \\u{1f622
3349
const a11 = tag`${ 100 }\u{1f622}` // \u{1f622}
50+
51+
!!! error TS1125: Hexadecimal digit expected.
3452
const a12 = tag`${ 100 }\x` // \\x
3553
const a13 = tag`${ 100 }\x0` // \\x0
3654
const a14 = tag`${ 100 }\x00` // \x00

0 commit comments

Comments
 (0)