From a2111843479cbae191eac29b58fd016069fc53e2 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Thu, 6 Dec 2018 11:17:06 -0800 Subject: [PATCH] Clarified error message; extended error to identifier end Lengthening the reported error length to include all of the identifier necessitates scanning for all of the identifier. I also reset the `pos` after so other identifier scanning still happens. --- src/compiler/diagnosticMessages.json | 2 +- src/compiler/scanner.ts | 9 +- ...ntifierStartAfterNumericLiteral.errors.txt | 116 ++++++++++++++---- .../identifierStartAfterNumericLiteral.js | 34 +++++ ...identifierStartAfterNumericLiteral.symbols | 13 ++ .../identifierStartAfterNumericLiteral.types | 56 +++++++++ ...ralsWithTrailingDecimalPoints01.errors.txt | 12 +- .../reference/parseBigInt.errors.txt | 12 +- ...umericSeparators.binaryNegative.errors.txt | 6 +- ...r.numericSeparators.hexNegative.errors.txt | 6 +- ...numericSeparators.octalNegative.errors.txt | 6 +- .../tsxAttributeInvalidNames.errors.txt | 6 +- .../identifierStartAfterNumericLiteral.ts | 13 ++ 13 files changed, 241 insertions(+), 50 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b7aaaf02742..cde7516f047 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1011,7 +1011,7 @@ "category": "Message", "code": 1350 }, - "An identifier cannot follow a numeric literal.": { + "An identifier or keyword cannot immediately follow a numeric literal.": { "category": "Error", "code": 1351 }, diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 1589cca8357..a9438110593 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -991,9 +991,14 @@ namespace ts { } function checkForIdentifierStartAfterNumericLiteral() { - if (isIdentifierStart(text.charCodeAt(pos), languageVersion)) { - error(Diagnostics.An_identifier_cannot_follow_a_numeric_literal, pos, 1); + if (!isIdentifierStart(text.charCodeAt(pos), languageVersion)) { + return; } + + const identifierStart = pos; + const { length } = scanIdentifierParts(); + error(Diagnostics.An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal, identifierStart, length); + pos = identifierStart; } function scanOctalDigits(): number { diff --git a/tests/baselines/reference/identifierStartAfterNumericLiteral.errors.txt b/tests/baselines/reference/identifierStartAfterNumericLiteral.errors.txt index 130e676d0d1..2b4884f7303 100644 --- a/tests/baselines/reference/identifierStartAfterNumericLiteral.errors.txt +++ b/tests/baselines/reference/identifierStartAfterNumericLiteral.errors.txt @@ -1,65 +1,135 @@ -tests/cases/compiler/identifierStartAfterNumericLiteral.ts(1,16): error TS1351: An identifier cannot follow a numeric literal. -tests/cases/compiler/identifierStartAfterNumericLiteral.ts(3,2): error TS1351: An identifier cannot follow a numeric literal. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(1,16): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(3,2): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. tests/cases/compiler/identifierStartAfterNumericLiteral.ts(3,2): error TS2304: Cannot find name 'a'. -tests/cases/compiler/identifierStartAfterNumericLiteral.ts(4,3): error TS1124: Digit expected. -tests/cases/compiler/identifierStartAfterNumericLiteral.ts(4,4): error TS2538: Type 'null' cannot be used as an index type. -tests/cases/compiler/identifierStartAfterNumericLiteral.ts(5,2): error TS1351: An identifier cannot follow a numeric literal. -tests/cases/compiler/identifierStartAfterNumericLiteral.ts(6,3): error TS1124: Digit expected. -tests/cases/compiler/identifierStartAfterNumericLiteral.ts(6,3): error TS2304: Cannot find name 'n'. -tests/cases/compiler/identifierStartAfterNumericLiteral.ts(7,2): error TS1351: An identifier cannot follow a numeric literal. -tests/cases/compiler/identifierStartAfterNumericLiteral.ts(7,2): error TS2304: Cannot find name 'a'. -tests/cases/compiler/identifierStartAfterNumericLiteral.ts(8,3): error TS1124: Digit expected. -tests/cases/compiler/identifierStartAfterNumericLiteral.ts(10,3): error TS1124: Digit expected. -tests/cases/compiler/identifierStartAfterNumericLiteral.ts(10,3): error TS2304: Cannot find name 'e'. -tests/cases/compiler/identifierStartAfterNumericLiteral.ts(12,3): error TS1005: ';' expected. -tests/cases/compiler/identifierStartAfterNumericLiteral.ts(13,3): error TS1351: An identifier cannot follow a numeric literal. -tests/cases/compiler/identifierStartAfterNumericLiteral.ts(13,3): error TS2304: Cannot find name 'a'. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(4,4): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(4,4): error TS2304: Cannot find name 'a'. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(5,3): error TS1124: Digit expected. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(5,4): error TS2538: Type 'null' cannot be used as an index type. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(6,5): error TS1124: Digit expected. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(6,6): error TS2538: Type 'null' cannot be used as an index type. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(7,2): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(8,4): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(9,3): error TS1124: Digit expected. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(9,3): error TS2304: Cannot find name 'n'. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(10,5): error TS1124: Digit expected. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(10,5): error TS2304: Cannot find name 'n'. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(11,2): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(11,2): error TS2304: Cannot find name 'a'. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(12,4): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(12,4): error TS2304: Cannot find name 'a'. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(13,4): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(13,4): error TS2304: Cannot find name 'abc'. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(14,3): error TS1124: Digit expected. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(15,5): error TS1124: Digit expected. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(18,3): error TS1124: Digit expected. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(18,3): error TS2304: Cannot find name 'e'. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(19,5): error TS1124: Digit expected. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(19,5): error TS2304: Cannot find name 'e'. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(22,3): error TS1005: ';' expected. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(23,5): error TS1005: ';' expected. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(24,3): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(24,3): error TS2304: Cannot find name 'a'. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(25,5): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(25,5): error TS2304: Cannot find name 'a'. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(26,5): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. +tests/cases/compiler/identifierStartAfterNumericLiteral.ts(26,5): error TS2304: Cannot find name 'abc'. -==== tests/cases/compiler/identifierStartAfterNumericLiteral.ts (16 errors) ==== +==== tests/cases/compiler/identifierStartAfterNumericLiteral.ts (35 errors) ==== let valueIn = 3in[null]; - ~ -!!! error TS1351: An identifier cannot follow a numeric literal. + ~~ +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. 3a[null] ~ -!!! error TS1351: An identifier cannot follow a numeric literal. +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. ~ +!!! error TS2304: Cannot find name 'a'. + 123a[null] + ~ +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. + ~ !!! error TS2304: Cannot find name 'a'. 3e[null] !!! error TS1124: Digit expected. ~~~~ +!!! error TS2538: Type 'null' cannot be used as an index type. + 123e[null] + +!!! error TS1124: Digit expected. + ~~~~ !!! error TS2538: Type 'null' cannot be used as an index type. 3in[null] - ~ -!!! error TS1351: An identifier cannot follow a numeric literal. + ~~ +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. + 123in[null] + ~~ +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. 3en[null] !!! error TS1124: Digit expected. ~ +!!! error TS2304: Cannot find name 'n'. + 123en[null] + +!!! error TS1124: Digit expected. + ~ !!! error TS2304: Cannot find name 'n'. 1a ~ -!!! error TS1351: An identifier cannot follow a numeric literal. +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. ~ !!! error TS2304: Cannot find name 'a'. + 123a + ~ +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. + ~ +!!! error TS2304: Cannot find name 'a'. + 123abc + ~~~ +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. + ~~~ +!!! error TS2304: Cannot find name 'abc'. 1e +!!! error TS1124: Digit expected. + 123e + !!! error TS1124: Digit expected. 1e9 + 123e9 1ee !!! error TS1124: Digit expected. ~ +!!! error TS2304: Cannot find name 'e'. + 123ee + +!!! error TS1124: Digit expected. + ~ !!! error TS2304: Cannot find name 'e'. 1n + 123n 2n2 ~ +!!! error TS1005: ';' expected. + 123n2 + ~ !!! error TS1005: ';' expected. 2na ~ -!!! error TS1351: An identifier cannot follow a numeric literal. +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. ~ !!! error TS2304: Cannot find name 'a'. + 123na + ~ +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. + ~ +!!! error TS2304: Cannot find name 'a'. + 123nabc + ~~~ +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. + ~~~ +!!! error TS2304: Cannot find name 'abc'. \ No newline at end of file diff --git a/tests/baselines/reference/identifierStartAfterNumericLiteral.js b/tests/baselines/reference/identifierStartAfterNumericLiteral.js index 0ec84716c2c..59ece3e1c7e 100644 --- a/tests/baselines/reference/identifierStartAfterNumericLiteral.js +++ b/tests/baselines/reference/identifierStartAfterNumericLiteral.js @@ -2,34 +2,68 @@ let valueIn = 3in[null]; 3a[null] +123a[null] 3e[null] +123e[null] 3in[null] +123in[null] 3en[null] +123en[null] 1a +123a +123abc 1e +123e 1e9 +123e9 1ee +123ee 1n +123n 2n2 +123n2 2na +123na +123nabc //// [identifierStartAfterNumericLiteral.js] var valueIn = 3 in [null]; 3; a[null]; +123; +a[null]; 3e[null]; +123e[null]; 3 in [null]; +123 in [null]; 3e; n[null]; +123e; +n[null]; 1; a; +123; +a; +123; +abc; 1e; +123e; 1e9; +123e9; 1e; e; +123e; +e; 1n; +123n; 2n; 2; +123n; +2; 2n; a; +123n; +a; +123n; +abc; diff --git a/tests/baselines/reference/identifierStartAfterNumericLiteral.symbols b/tests/baselines/reference/identifierStartAfterNumericLiteral.symbols index 71b253dbecc..8237191eee4 100644 --- a/tests/baselines/reference/identifierStartAfterNumericLiteral.symbols +++ b/tests/baselines/reference/identifierStartAfterNumericLiteral.symbols @@ -3,14 +3,27 @@ let valueIn = 3in[null]; >valueIn : Symbol(valueIn, Decl(identifierStartAfterNumericLiteral.ts, 0, 3)) 3a[null] +123a[null] 3e[null] +123e[null] 3in[null] +123in[null] 3en[null] +123en[null] 1a +123a +123abc 1e +123e 1e9 +123e9 1ee +123ee 1n +123n 2n2 +123n2 2na +123na +123nabc diff --git a/tests/baselines/reference/identifierStartAfterNumericLiteral.types b/tests/baselines/reference/identifierStartAfterNumericLiteral.types index b31c9ee8d11..af3399a6d13 100644 --- a/tests/baselines/reference/identifierStartAfterNumericLiteral.types +++ b/tests/baselines/reference/identifierStartAfterNumericLiteral.types @@ -12,45 +12,101 @@ let valueIn = 3in[null]; >a : any >null : null +123a[null] +>123 : 123 +>a[null] : any +>a : any +>null : null + 3e[null] >3e[null] : any >3e : 3 >null : null +123e[null] +>123e[null] : any +>123e : 123 +>null : null + 3in[null] >3in[null] : boolean >3 : 3 >[null] : null[] >null : null +123in[null] +>123in[null] : boolean +>123 : 123 +>[null] : null[] +>null : null + 3en[null] >3e : 3 >n[null] : any >n : any >null : null +123en[null] +>123e : 123 +>n[null] : any +>n : any +>null : null + 1a >1 : 1 >a : any +123a +>123 : 123 +>a : any + +123abc +>123 : 123 +>abc : any + 1e >1e : 1 +123e +>123e : 123 + 1e9 >1e9 : 1000000000 +123e9 +>123e9 : 123000000000 + 1ee >1e : 1 >e : any +123ee +>123e : 123 +>e : any + 1n >1n : 1n +123n +>123n : 123n + 2n2 >2n : 2n >2 : 2 +123n2 +>123n : 123n +>2 : 2 + 2na >2n : 2n >a : any +123na +>123n : 123n +>a : any + +123nabc +>123n : 123n +>abc : any + diff --git a/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.errors.txt b/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.errors.txt index 42561707d56..ac319184f8a 100644 --- a/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.errors.txt +++ b/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(3,3): error TS1351: An identifier cannot follow a numeric literal. -tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,15): error TS1351: An identifier cannot follow a numeric literal. +tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(3,3): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. +tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,15): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,23): error TS1005: ',' expected. tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,24): error TS1109: Expression expected. @@ -8,16 +8,16 @@ tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,24): error 1..toString(); 1.0.toString(); 1.toString(); - ~ -!!! error TS1351: An identifier cannot follow a numeric literal. + ~~~~~~~~ +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. 1.+2.0 + 3. ; // Preserve whitespace where important for JS compatibility var i: number = 1; var test1 = i.toString(); var test2 = 2.toString(); - ~ -!!! error TS1351: An identifier cannot follow a numeric literal. + ~~~~~~~~ +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. ~ !!! error TS1005: ',' expected. ~ diff --git a/tests/baselines/reference/parseBigInt.errors.txt b/tests/baselines/reference/parseBigInt.errors.txt index 77d8b55ed98..16878e75fe9 100644 --- a/tests/baselines/reference/parseBigInt.errors.txt +++ b/tests/baselines/reference/parseBigInt.errors.txt @@ -1,9 +1,9 @@ tests/cases/compiler/parseBigInt.ts(51,20): error TS2736: Operator '+' cannot be applied to type '123n'. tests/cases/compiler/parseBigInt.ts(52,23): error TS2736: Operator '+' cannot be applied to type '291n'. tests/cases/compiler/parseBigInt.ts(56,25): error TS1005: ',' expected. -tests/cases/compiler/parseBigInt.ts(57,25): error TS1351: An identifier cannot follow a numeric literal. -tests/cases/compiler/parseBigInt.ts(58,22): error TS1351: An identifier cannot follow a numeric literal. -tests/cases/compiler/parseBigInt.ts(59,28): error TS1351: An identifier cannot follow a numeric literal. +tests/cases/compiler/parseBigInt.ts(57,25): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. +tests/cases/compiler/parseBigInt.ts(58,22): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. +tests/cases/compiler/parseBigInt.ts(59,28): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. tests/cases/compiler/parseBigInt.ts(60,23): error TS1177: Binary digit expected. tests/cases/compiler/parseBigInt.ts(61,20): error TS1178: Octal digit expected. tests/cases/compiler/parseBigInt.ts(62,20): error TS1125: Hexadecimal digit expected. @@ -82,13 +82,13 @@ tests/cases/compiler/parseBigInt.ts(70,72): error TS2345: Argument of type '3' i !!! error TS1005: ',' expected. { const scientific = 1e2n; } ~ -!!! error TS1351: An identifier cannot follow a numeric literal. +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. { const decimal = 4.1n; } ~ -!!! error TS1351: An identifier cannot follow a numeric literal. +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. { const leadingDecimal = .1n; } ~ -!!! error TS1351: An identifier cannot follow a numeric literal. +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. const emptyBinary = 0bn; // should error but infer 0n !!! error TS1177: Binary digit expected. diff --git a/tests/baselines/reference/parser.numericSeparators.binaryNegative.errors.txt b/tests/baselines/reference/parser.numericSeparators.binaryNegative.errors.txt index bff028ba704..93118bc9c7f 100644 --- a/tests/baselines/reference/parser.numericSeparators.binaryNegative.errors.txt +++ b/tests/baselines/reference/parser.numericSeparators.binaryNegative.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/1.ts(1,5): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/2.ts(1,3): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/3.ts(1,2): error TS6188: Numeric separators are not allowed here. -tests/cases/conformance/parser/ecmascriptnext/numericSeparators/3.ts(1,3): error TS1351: An identifier cannot follow a numeric literal. +tests/cases/conformance/parser/ecmascriptnext/numericSeparators/3.ts(1,3): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/3.ts(1,3): error TS2304: Cannot find name 'B0101'. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/4.ts(1,6): error TS6189: Multiple consecutive numeric separators are not permitted. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/5.ts(1,13): error TS6189: Multiple consecutive numeric separators are not permitted. @@ -24,8 +24,8 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/6.ts(1,5): error 0_B0101 ~ !!! error TS6188: Numeric separators are not allowed here. - ~ -!!! error TS1351: An identifier cannot follow a numeric literal. + ~~~~~ +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. ~~~~~ !!! error TS2304: Cannot find name 'B0101'. diff --git a/tests/baselines/reference/parser.numericSeparators.hexNegative.errors.txt b/tests/baselines/reference/parser.numericSeparators.hexNegative.errors.txt index 3aca519e572..c6048a1bbfb 100644 --- a/tests/baselines/reference/parser.numericSeparators.hexNegative.errors.txt +++ b/tests/baselines/reference/parser.numericSeparators.hexNegative.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/1.ts(1,5): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/2.ts(1,3): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/3.ts(1,2): error TS6188: Numeric separators are not allowed here. -tests/cases/conformance/parser/ecmascriptnext/numericSeparators/3.ts(1,3): error TS1351: An identifier cannot follow a numeric literal. +tests/cases/conformance/parser/ecmascriptnext/numericSeparators/3.ts(1,3): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/3.ts(1,3): error TS2304: Cannot find name 'X0101'. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/4.ts(1,6): error TS6189: Multiple consecutive numeric separators are not permitted. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/5.ts(1,13): error TS6189: Multiple consecutive numeric separators are not permitted. @@ -24,8 +24,8 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/6.ts(1,5): error 0_X0101 ~ !!! error TS6188: Numeric separators are not allowed here. - ~ -!!! error TS1351: An identifier cannot follow a numeric literal. + ~~~~~ +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. ~~~~~ !!! error TS2304: Cannot find name 'X0101'. diff --git a/tests/baselines/reference/parser.numericSeparators.octalNegative.errors.txt b/tests/baselines/reference/parser.numericSeparators.octalNegative.errors.txt index 58c1363b7ba..ebdec3371aa 100644 --- a/tests/baselines/reference/parser.numericSeparators.octalNegative.errors.txt +++ b/tests/baselines/reference/parser.numericSeparators.octalNegative.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/1.ts(1,5): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/2.ts(1,3): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/3.ts(1,2): error TS6188: Numeric separators are not allowed here. -tests/cases/conformance/parser/ecmascriptnext/numericSeparators/3.ts(1,3): error TS1351: An identifier cannot follow a numeric literal. +tests/cases/conformance/parser/ecmascriptnext/numericSeparators/3.ts(1,3): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/3.ts(1,3): error TS2304: Cannot find name 'O0101'. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/4.ts(1,6): error TS6189: Multiple consecutive numeric separators are not permitted. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/5.ts(1,13): error TS6189: Multiple consecutive numeric separators are not permitted. @@ -24,8 +24,8 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/6.ts(1,5): error 0_O0101 ~ !!! error TS6188: Numeric separators are not allowed here. - ~ -!!! error TS1351: An identifier cannot follow a numeric literal. + ~~~~~ +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. ~~~~~ !!! error TS2304: Cannot find name 'O0101'. diff --git a/tests/baselines/reference/tsxAttributeInvalidNames.errors.txt b/tests/baselines/reference/tsxAttributeInvalidNames.errors.txt index 65b2fc23803..d0b521d0454 100644 --- a/tests/baselines/reference/tsxAttributeInvalidNames.errors.txt +++ b/tests/baselines/reference/tsxAttributeInvalidNames.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/jsx/file.tsx(10,8): error TS1003: Identifier expected. -tests/cases/conformance/jsx/file.tsx(10,10): error TS1351: An identifier cannot follow a numeric literal. tests/cases/conformance/jsx/file.tsx(10,10): error TS1005: ';' expected. +tests/cases/conformance/jsx/file.tsx(10,10): error TS1351: An identifier or keyword cannot immediately follow a numeric literal. tests/cases/conformance/jsx/file.tsx(10,10): error TS2304: Cannot find name 'data'. tests/cases/conformance/jsx/file.tsx(10,15): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. tests/cases/conformance/jsx/file.tsx(10,18): error TS1005: ':' expected. @@ -26,11 +26,11 @@ tests/cases/conformance/jsx/file.tsx(11,20): error TS1161: Unterminated regular ; ~~ !!! error TS1003: Identifier expected. - ~ -!!! error TS1351: An identifier cannot follow a numeric literal. ~~~~ !!! error TS1005: ';' expected. ~~~~ +!!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. + ~~~~ !!! error TS2304: Cannot find name 'data'. ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. diff --git a/tests/cases/compiler/identifierStartAfterNumericLiteral.ts b/tests/cases/compiler/identifierStartAfterNumericLiteral.ts index 80e4760e11b..14e5cca0e25 100644 --- a/tests/cases/compiler/identifierStartAfterNumericLiteral.ts +++ b/tests/cases/compiler/identifierStartAfterNumericLiteral.ts @@ -1,13 +1,26 @@ let valueIn = 3in[null]; 3a[null] +123a[null] 3e[null] +123e[null] 3in[null] +123in[null] 3en[null] +123en[null] 1a +123a +123abc 1e +123e 1e9 +123e9 1ee +123ee 1n +123n 2n2 +123n2 2na +123na +123nabc