diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index f61aa3ab900eb..862e43748d705 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2266,8 +2266,13 @@ namespace ts { } function checkStrictModeNumericLiteral(node: NumericLiteral) { - if (inStrictMode && node.numericLiteralFlags & TokenFlags.Octal) { - file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); + if (inStrictMode) { + if (node.numericLiteralFlags & TokenFlags.Octal) { + file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); + } + else if (node.numericLiteralFlags & TokenFlags.StartsWithZero) { + file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Number_literals_starting_with_0_are_not_allowed_in_strict_mode)); + } } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index d0d66f0f959b8..d9250e34cf16c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1180,6 +1180,14 @@ "category": "Error", "code": 1388 }, + "Number literals starting with '0' are not allowed in strict mode.": { + "category": "Error", + "code": 1389 + }, + "A bigint literal cannot start with '0'.": { + "category": "Error", + "code": 1390 + }, "The types of '{0}' are incompatible between these types.": { "category": "Error", @@ -4677,6 +4685,10 @@ "category": "Error", "code": 6504 }, + "Numeric separators are not allowed in numbers that start with '0'.": { + "category": "Error", + "code": 6505 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 77ec82ffef760..f34e5e37176eb 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -1094,6 +1094,116 @@ namespace ts { } } + function scanPotentiallyOctalNumberFragment(): { fragment: string, isOctalCandidate: boolean } { + let start = pos; + let allowSeparator = false; + let isPreviousTokenSeparator = false; + let shouldShowLeadingZeroError = true; + let isOctalCandidate = pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1)); + let result = ""; + while (true) { + const ch = text.charCodeAt(pos); + if (ch === CharacterCodes._) { + tokenFlags |= TokenFlags.ContainsSeparator; + isOctalCandidate = false; + if (allowSeparator) { + allowSeparator = false; + isPreviousTokenSeparator = true; + result += text.substring(start, pos); + } + else if (isPreviousTokenSeparator) { + error(Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1); + } + else { + error(Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1); + } + if (shouldShowLeadingZeroError) { + error(Diagnostics.Numeric_separators_are_not_allowed_in_numbers_that_start_with_0, pos, 1); + shouldShowLeadingZeroError = false; + } + pos++; + start = pos; + continue; + } + if (isDigit(ch)) { + if (!isOctalDigit(ch)) { + isOctalCandidate = false; + } + allowSeparator = true; + isPreviousTokenSeparator = false; + pos++; + continue; + } + break; + } + if (text.charCodeAt(pos - 1) === CharacterCodes._) { + error(Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); + } + return { fragment: result + text.substring(start, pos), isOctalCandidate }; + } + + function scanZeroLeadingNumber(): { type: SyntaxKind, value: string } { + const start = pos; + const { fragment: mainFragment, isOctalCandidate } = scanPotentiallyOctalNumberFragment(); + let decimalFragment: string | undefined; + let scientificFragment: string | undefined; + if (text.charCodeAt(pos) === CharacterCodes.dot && !(isOctalCandidate && isIdentifierStart(codePointAt(text, pos + 1), languageVersion))) { + pos++; + decimalFragment = scanNumberFragment(); + } + let end = pos; + if (text.charCodeAt(pos) === CharacterCodes.E || text.charCodeAt(pos) === CharacterCodes.e) { + pos++; + tokenFlags |= TokenFlags.Scientific; + if (text.charCodeAt(pos) === CharacterCodes.plus || text.charCodeAt(pos) === CharacterCodes.minus) pos++; + const preNumericPart = pos; + const finalFragment = scanNumberFragment(); + if (!finalFragment) { + error(Diagnostics.Digit_expected); + } + else { + scientificFragment = text.substring(end, preNumericPart) + finalFragment; + end = pos; + } + } + let result: string; + if (tokenFlags & TokenFlags.ContainsSeparator) { + result = mainFragment; + if (decimalFragment) { + result += "." + decimalFragment; + } + if (scientificFragment) { + result += scientificFragment; + } + } + else { + result = text.substring(start, end); // No need to use all the fragments; no _ removal needed + } + + if (decimalFragment !== undefined || tokenFlags & TokenFlags.Scientific) { + checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & TokenFlags.Scientific)); + return { + type: SyntaxKind.NumericLiteral, + value: "" + +result // if value is not an integer, it can be safely coerced to a number + }; + } + else { + let type = SyntaxKind.NumericLiteral; + tokenValue = "" + +result; + if (text.charCodeAt(pos) === CharacterCodes.n) { + type = SyntaxKind.BigIntLiteral; + tokenValue = parsePseudoBigInt(tokenValue + "n") + "n"; + pos++; + error(Diagnostics.A_bigint_literal_cannot_start_with_0, start, pos - start); + } + else if (isOctalCandidate) { + tokenFlags |= TokenFlags.Octal; + } + checkForIdentifierStartAfterNumericLiteral(start); + return { type, value: tokenValue }; + } + } + function checkForIdentifierStartAfterNumericLiteral(numericStart: number, isScientific?: boolean) { if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) { return; @@ -1116,14 +1226,6 @@ namespace ts { } } - function scanOctalDigits(): number { - const start = pos; - while (isOctalDigit(text.charCodeAt(pos))) { - pos++; - } - return +(text.substring(start, pos)); - } - /** * Scans the given number of hexadecimal digits in the text, * returning -1 if the given number is unavailable. @@ -1852,16 +1954,13 @@ namespace ts { tokenFlags |= TokenFlags.OctalSpecifier; return token = checkBigIntSuffix(); } - // Try to parse as an octal - if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { - tokenValue = "" + scanOctalDigits(); - tokenFlags |= TokenFlags.Octal; - return token = SyntaxKind.NumericLiteral; + else if (pos + 1 < end && (isDigit(text.charCodeAt(pos + 1)) || text.charCodeAt(pos + 1) === CharacterCodes._)) { + tokenFlags |= TokenFlags.StartsWithZero; + ({ type: token, value: tokenValue } = scanZeroLeadingNumber()); + return token; } - // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero - // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being - // permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do). - // falls through + + // Fallthrough only for single digit number '0' or number starting with '0.' which don't need special checks case CharacterCodes._1: case CharacterCodes._2: case CharacterCodes._3: diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 0db378efd7b36..ef372077f0945 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2078,9 +2078,11 @@ namespace ts { /* @internal */ ContainsInvalidEscape = 1 << 11, // e.g. `\uhello` /* @internal */ + StartsWithZero = 1 << 12, + /* @internal */ BinaryOrOctalSpecifier = BinarySpecifier | OctalSpecifier, /* @internal */ - NumericLiteralFlags = Scientific | Octal | HexSpecifier | BinaryOrOctalSpecifier | ContainsSeparator, + NumericLiteralFlags = Scientific | Octal | HexSpecifier | BinaryOrOctalSpecifier | ContainsSeparator | StartsWithZero, /* @internal */ TemplateLiteralLikeFlags = ContainsInvalidEscape, } diff --git a/tests/baselines/reference/jsFileCompilationBindStrictModeErrors.errors.txt b/tests/baselines/reference/jsFileCompilationBindStrictModeErrors.errors.txt index f2d68282c67fd..011d66dd62c19 100644 --- a/tests/baselines/reference/jsFileCompilationBindStrictModeErrors.errors.txt +++ b/tests/baselines/reference/jsFileCompilationBindStrictModeErrors.errors.txt @@ -11,8 +11,7 @@ tests/cases/compiler/b.js(3,7): error TS1210: Invalid use of 'eval'. Class defin tests/cases/compiler/b.js(6,13): error TS1213: Identifier expected. 'let' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/compiler/c.js(1,12): error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode. tests/cases/compiler/c.js(2,5): error TS1215: Invalid use of 'eval'. Modules are automatically in strict mode. -tests/cases/compiler/d.js(2,9): error TS1121: Octal literals are not allowed in strict mode. -tests/cases/compiler/d.js(2,11): error TS1005: ',' expected. +tests/cases/compiler/d.js(2,9): error TS1389: Number literals starting with '0' are not allowed in strict mode. ==== tests/cases/compiler/a.js (9 errors) ==== @@ -75,10 +74,8 @@ tests/cases/compiler/d.js(2,11): error TS1005: ',' expected. !!! error TS1215: Invalid use of 'eval'. Modules are automatically in strict mode. }; -==== tests/cases/compiler/d.js (2 errors) ==== +==== tests/cases/compiler/d.js (1 errors) ==== "use strict"; var x = 009; // error - ~~ -!!! error TS1121: Octal literals are not allowed in strict mode. - ~ -!!! error TS1005: ',' expected. \ No newline at end of file + ~~~ +!!! error TS1389: Number literals starting with '0' are not allowed in strict mode. \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationBindStrictModeErrors.types b/tests/baselines/reference/jsFileCompilationBindStrictModeErrors.types index 4f59172ff9ace..814df00a7fc33 100644 --- a/tests/baselines/reference/jsFileCompilationBindStrictModeErrors.types +++ b/tests/baselines/reference/jsFileCompilationBindStrictModeErrors.types @@ -79,6 +79,5 @@ var eval = function () { var x = 009; // error >x : number ->00 : 0 ->9 : 9 +>009 : 9 diff --git a/tests/baselines/reference/parseBigInt.errors.txt b/tests/baselines/reference/parseBigInt.errors.txt index 4641e88f13774..6c1782db7007e 100644 --- a/tests/baselines/reference/parseBigInt.errors.txt +++ b/tests/baselines/reference/parseBigInt.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/parseBigInt.ts(51,20): error TS2736: Operator '+' cannot be applied to type 'bigint'. tests/cases/compiler/parseBigInt.ts(52,23): error TS2736: Operator '+' cannot be applied to type 'bigint'. -tests/cases/compiler/parseBigInt.ts(56,25): error TS1005: ',' expected. +tests/cases/compiler/parseBigInt.ts(56,21): error TS1390: A bigint literal cannot start with '0'. tests/cases/compiler/parseBigInt.ts(57,22): error TS1352: A bigint literal cannot use exponential notation. tests/cases/compiler/parseBigInt.ts(58,19): error TS1353: A bigint literal must be an integer. tests/cases/compiler/parseBigInt.ts(59,26): error TS1353: A bigint literal must be an integer. @@ -78,8 +78,8 @@ tests/cases/compiler/parseBigInt.ts(70,72): error TS2345: Argument of type '3' i // Parsing errors // In separate blocks because they each declare an "n" variable { const legacyOct = 0123n; } - ~ -!!! error TS1005: ',' expected. + ~~~~~ +!!! error TS1390: A bigint literal cannot start with '0'. { const scientific = 1e2n; } ~~~~ !!! error TS1352: A bigint literal cannot use exponential notation. diff --git a/tests/baselines/reference/parseBigInt.js b/tests/baselines/reference/parseBigInt.js index 1ffccb11e64fe..c8cb855d50400 100644 --- a/tests/baselines/reference/parseBigInt.js +++ b/tests/baselines/reference/parseBigInt.js @@ -120,7 +120,7 @@ const unaryPlusHex = +0x123n; // Parsing errors // In separate blocks because they each declare an "n" variable { - const legacyOct = 0123, n; + const legacyOct = 123n; } { const scientific = 1e2n; diff --git a/tests/baselines/reference/parseBigInt.symbols b/tests/baselines/reference/parseBigInt.symbols index 89ce1a8173ba5..0b1cb8ae608e1 100644 --- a/tests/baselines/reference/parseBigInt.symbols +++ b/tests/baselines/reference/parseBigInt.symbols @@ -127,7 +127,6 @@ const unaryPlusHex = +0x123n; // In separate blocks because they each declare an "n" variable { const legacyOct = 0123n; } >legacyOct : Symbol(legacyOct, Decl(parseBigInt.ts, 55, 7)) ->n : Symbol(n, Decl(parseBigInt.ts, 55, 24)) { const scientific = 1e2n; } >scientific : Symbol(scientific, Decl(parseBigInt.ts, 56, 7)) diff --git a/tests/baselines/reference/parseBigInt.types b/tests/baselines/reference/parseBigInt.types index 70fd3fa3a600a..a29555c303200 100644 --- a/tests/baselines/reference/parseBigInt.types +++ b/tests/baselines/reference/parseBigInt.types @@ -174,9 +174,8 @@ const unaryPlusHex = +0x123n; // Parsing errors // In separate blocks because they each declare an "n" variable { const legacyOct = 0123n; } ->legacyOct : 123 ->0123 : 123 ->n : any +>legacyOct : 123n +>0123n : 123n { const scientific = 1e2n; } >scientific : 100 diff --git a/tests/baselines/reference/parser.numericSeparators.binaryNegative.errors.txt b/tests/baselines/reference/parser.numericSeparators.binaryNegative.errors.txt index 93118bc9c7fb7..ebbb90c3281d0 100644 --- a/tests/baselines/reference/parser.numericSeparators.binaryNegative.errors.txt +++ b/tests/baselines/reference/parser.numericSeparators.binaryNegative.errors.txt @@ -1,6 +1,6 @@ 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,2): error TS6505: Numeric separators are not allowed in numbers that start with '0'. 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. @@ -23,7 +23,7 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/6.ts(1,5): error ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/3.ts (3 errors) ==== 0_B0101 ~ -!!! error TS6188: Numeric separators are not allowed here. +!!! error TS6505: Numeric separators are not allowed in numbers that start with '0'. ~~~~~ !!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. ~~~~~ diff --git a/tests/baselines/reference/parser.numericSeparators.decmialNegative.errors.txt b/tests/baselines/reference/parser.numericSeparators.decmialNegative.errors.txt index 8e48e7c1750e6..b84f2ff6c32a9 100644 --- a/tests/baselines/reference/parser.numericSeparators.decmialNegative.errors.txt +++ b/tests/baselines/reference/parser.numericSeparators.decmialNegative.errors.txt @@ -1,22 +1,23 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/1.ts(1,1): error TS2304: Cannot find name '_10'. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/10.ts(1,4): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/11.ts(1,5): error TS6189: Multiple consecutive numeric separators are not permitted. -tests/cases/conformance/parser/ecmascriptnext/numericSeparators/12.ts(1,2): error TS6188: Numeric separators are not allowed here. +tests/cases/conformance/parser/ecmascriptnext/numericSeparators/12.ts(1,2): error TS6505: Numeric separators are not allowed in numbers that start with '0'. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/13.ts(1,3): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/14.ts(1,4): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/15.ts(1,5): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/16.ts(1,1): error TS2304: Cannot find name '_0'. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/16.ts(1,3): error TS1005: ';' expected. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/17.ts(1,6): error TS6188: Numeric separators are not allowed here. +tests/cases/conformance/parser/ecmascriptnext/numericSeparators/18.ts(1,2): error TS6505: Numeric separators are not allowed in numbers that start with '0'. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/18.ts(1,3): error TS6189: Multiple consecutive numeric separators are not permitted. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/19.ts(1,5): error TS6189: Multiple consecutive numeric separators are not permitted. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/2.ts(1,3): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/20.ts(1,8): error TS6189: Multiple consecutive numeric separators are not permitted. -tests/cases/conformance/parser/ecmascriptnext/numericSeparators/21.ts(1,2): error TS6188: Numeric separators are not allowed here. +tests/cases/conformance/parser/ecmascriptnext/numericSeparators/21.ts(1,2): error TS6505: Numeric separators are not allowed in numbers that start with '0'. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/22.ts(1,4): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/23.ts(1,5): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/24.ts(1,6): error TS6189: Multiple consecutive numeric separators are not permitted. -tests/cases/conformance/parser/ecmascriptnext/numericSeparators/25.ts(1,2): error TS6188: Numeric separators are not allowed here. +tests/cases/conformance/parser/ecmascriptnext/numericSeparators/25.ts(1,2): error TS6505: Numeric separators are not allowed in numbers that start with '0'. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/26.ts(1,3): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/27.ts(1,4): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/28.ts(1,6): error TS6188: Numeric separators are not allowed here. @@ -24,21 +25,23 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/29.ts(1,1): erro tests/cases/conformance/parser/ecmascriptnext/numericSeparators/29.ts(1,3): error TS1005: ';' expected. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/3.ts(1,3): error TS6189: Multiple consecutive numeric separators are not permitted. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/30.ts(1,7): error TS6188: Numeric separators are not allowed here. +tests/cases/conformance/parser/ecmascriptnext/numericSeparators/31.ts(1,2): error TS6505: Numeric separators are not allowed in numbers that start with '0'. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/31.ts(1,3): error TS6189: Multiple consecutive numeric separators are not permitted. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/32.ts(1,5): error TS6189: Multiple consecutive numeric separators are not permitted. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/33.ts(1,9): error TS6189: Multiple consecutive numeric separators are not permitted. -tests/cases/conformance/parser/ecmascriptnext/numericSeparators/34.ts(1,2): error TS6188: Numeric separators are not allowed here. +tests/cases/conformance/parser/ecmascriptnext/numericSeparators/34.ts(1,2): error TS6505: Numeric separators are not allowed in numbers that start with '0'. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/35.ts(1,4): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/36.ts(1,5): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/37.ts(1,6): error TS6189: Multiple consecutive numeric separators are not permitted. -tests/cases/conformance/parser/ecmascriptnext/numericSeparators/38.ts(1,2): error TS6188: Numeric separators are not allowed here. +tests/cases/conformance/parser/ecmascriptnext/numericSeparators/38.ts(1,2): error TS6505: Numeric separators are not allowed in numbers that start with '0'. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/39.ts(1,3): error TS6188: Numeric separators are not allowed here. -tests/cases/conformance/parser/ecmascriptnext/numericSeparators/4.ts(1,2): error TS6188: Numeric separators are not allowed here. +tests/cases/conformance/parser/ecmascriptnext/numericSeparators/4.ts(1,2): error TS6505: Numeric separators are not allowed in numbers that start with '0'. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/40.ts(1,4): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/41.ts(1,6): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/42.ts(1,1): error TS2304: Cannot find name '_0'. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/42.ts(1,3): error TS1005: ';' expected. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/43.ts(1,7): error TS6188: Numeric separators are not allowed here. +tests/cases/conformance/parser/ecmascriptnext/numericSeparators/44.ts(1,2): error TS6505: Numeric separators are not allowed in numbers that start with '0'. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/44.ts(1,3): error TS6189: Multiple consecutive numeric separators are not permitted. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/45.ts(1,5): error TS6189: Multiple consecutive numeric separators are not permitted. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/46.ts(1,9): error TS6189: Multiple consecutive numeric separators are not permitted. @@ -52,9 +55,11 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/5.ts(1,3): error tests/cases/conformance/parser/ecmascriptnext/numericSeparators/50.ts(1,5): error TS6188: Numeric separators are not allowed here. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/50.ts(1,6): error TS1124: Digit expected. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/51.ts(1,3): error TS6188: Numeric separators are not allowed here. +tests/cases/conformance/parser/ecmascriptnext/numericSeparators/52.ts(1,3): error TS6505: Numeric separators are not allowed in numbers that start with '0'. +tests/cases/conformance/parser/ecmascriptnext/numericSeparators/53.ts(1,3): error TS6505: Numeric separators are not allowed in numbers that start with '0'. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/6.ts(1,5): error TS6189: Multiple consecutive numeric separators are not permitted. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/7.ts(1,5): error TS6189: Multiple consecutive numeric separators are not permitted. -tests/cases/conformance/parser/ecmascriptnext/numericSeparators/8.ts(1,2): error TS6188: Numeric separators are not allowed here. +tests/cases/conformance/parser/ecmascriptnext/numericSeparators/8.ts(1,2): error TS6505: Numeric separators are not allowed in numbers that start with '0'. tests/cases/conformance/parser/ecmascriptnext/numericSeparators/9.ts(1,3): error TS6188: Numeric separators are not allowed here. @@ -76,7 +81,7 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/9.ts(1,3): error ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/4.ts (1 errors) ==== 0_.0 ~ -!!! error TS6188: Numeric separators are not allowed here. +!!! error TS6505: Numeric separators are not allowed in numbers that start with '0'. ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/5.ts (1 errors) ==== 0._0 @@ -96,7 +101,7 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/9.ts(1,3): error ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/8.ts (1 errors) ==== 0_e0 ~ -!!! error TS6188: Numeric separators are not allowed here. +!!! error TS6505: Numeric separators are not allowed in numbers that start with '0'. ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/9.ts (1 errors) ==== 0e_0 @@ -116,7 +121,7 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/9.ts(1,3): error ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/12.ts (1 errors) ==== 0_.0e0 ~ -!!! error TS6188: Numeric separators are not allowed here. +!!! error TS6505: Numeric separators are not allowed in numbers that start with '0'. ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/13.ts (1 errors) ==== 0._0e0 @@ -145,8 +150,10 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/9.ts(1,3): error ~ !!! error TS6188: Numeric separators are not allowed here. -==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/18.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/18.ts (2 errors) ==== 0__0.0e0 + ~ +!!! error TS6505: Numeric separators are not allowed in numbers that start with '0'. ~ !!! error TS6189: Multiple consecutive numeric separators are not permitted. @@ -163,7 +170,7 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/9.ts(1,3): error ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/21.ts (1 errors) ==== 0_e+0 ~ -!!! error TS6188: Numeric separators are not allowed here. +!!! error TS6505: Numeric separators are not allowed in numbers that start with '0'. ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/22.ts (1 errors) ==== 0e+_0 @@ -183,7 +190,7 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/9.ts(1,3): error ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/25.ts (1 errors) ==== 0_.0e+0 ~ -!!! error TS6188: Numeric separators are not allowed here. +!!! error TS6505: Numeric separators are not allowed in numbers that start with '0'. ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/26.ts (1 errors) ==== 0._0e+0 @@ -212,8 +219,10 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/9.ts(1,3): error ~ !!! error TS6188: Numeric separators are not allowed here. -==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/31.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/31.ts (2 errors) ==== 0__0.0e+0 + ~ +!!! error TS6505: Numeric separators are not allowed in numbers that start with '0'. ~ !!! error TS6189: Multiple consecutive numeric separators are not permitted. @@ -230,7 +239,7 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/9.ts(1,3): error ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/34.ts (1 errors) ==== 0_e+0 ~ -!!! error TS6188: Numeric separators are not allowed here. +!!! error TS6505: Numeric separators are not allowed in numbers that start with '0'. ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/35.ts (1 errors) ==== 0e-_0 @@ -250,7 +259,7 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/9.ts(1,3): error ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/38.ts (1 errors) ==== 0_.0e-0 ~ -!!! error TS6188: Numeric separators are not allowed here. +!!! error TS6505: Numeric separators are not allowed in numbers that start with '0'. ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/39.ts (1 errors) ==== 0._0e-0 @@ -279,8 +288,10 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/9.ts(1,3): error ~ !!! error TS6188: Numeric separators are not allowed here. -==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/44.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/44.ts (2 errors) ==== 0__0.0e-0 + ~ +!!! error TS6505: Numeric separators are not allowed in numbers that start with '0'. ~ !!! error TS6189: Multiple consecutive numeric separators are not permitted. @@ -326,4 +337,14 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/9.ts(1,3): error 0._ ~ !!! error TS6188: Numeric separators are not allowed here. + +==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/52.ts (1 errors) ==== + 09_0 + ~ +!!! error TS6505: Numeric separators are not allowed in numbers that start with '0'. + +==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/53.ts (1 errors) ==== + 07_0 + ~ +!!! error TS6505: Numeric separators are not allowed in numbers that start with '0'. \ No newline at end of file diff --git a/tests/baselines/reference/parser.numericSeparators.decmialNegative.js b/tests/baselines/reference/parser.numericSeparators.decmialNegative.js index 2ccffcc146067..c7d7c8b649cca 100644 --- a/tests/baselines/reference/parser.numericSeparators.decmialNegative.js +++ b/tests/baselines/reference/parser.numericSeparators.decmialNegative.js @@ -153,6 +153,12 @@ _0.0e-0 //// [51.ts] 0._ +//// [52.ts] +09_0 + +//// [53.ts] +07_0 + //// [1.js] _10; @@ -260,3 +266,7 @@ _; 1 - 10; //// [51.js] 0; +//// [52.js] +90; +//// [53.js] +70; diff --git a/tests/baselines/reference/parser.numericSeparators.decmialNegative.symbols b/tests/baselines/reference/parser.numericSeparators.decmialNegative.symbols index daa418358b988..2cee977ce0be1 100644 --- a/tests/baselines/reference/parser.numericSeparators.decmialNegative.symbols +++ b/tests/baselines/reference/parser.numericSeparators.decmialNegative.symbols @@ -151,4 +151,10 @@ No type information for this code. No type information for this code.=== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/51.ts === 0._ No type information for this code. +No type information for this code.=== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/52.ts === +09_0 +No type information for this code. +No type information for this code.=== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/53.ts === +07_0 +No type information for this code. No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/parser.numericSeparators.decmialNegative.types b/tests/baselines/reference/parser.numericSeparators.decmialNegative.types index 84ab9b585b90e..ccd94f949ee36 100644 --- a/tests/baselines/reference/parser.numericSeparators.decmialNegative.types +++ b/tests/baselines/reference/parser.numericSeparators.decmialNegative.types @@ -210,3 +210,11 @@ _0.0e-0 0._ >0._ : 0 +=== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/52.ts === +09_0 +>09_0 : 90 + +=== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/53.ts === +07_0 +>07_0 : 70 + diff --git a/tests/baselines/reference/parser.numericSeparators.hexNegative.errors.txt b/tests/baselines/reference/parser.numericSeparators.hexNegative.errors.txt index c6048a1bbfb4c..2638591aeeae8 100644 --- a/tests/baselines/reference/parser.numericSeparators.hexNegative.errors.txt +++ b/tests/baselines/reference/parser.numericSeparators.hexNegative.errors.txt @@ -1,6 +1,6 @@ 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,2): error TS6505: Numeric separators are not allowed in numbers that start with '0'. 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. @@ -23,7 +23,7 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/6.ts(1,5): error ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/3.ts (3 errors) ==== 0_X0101 ~ -!!! error TS6188: Numeric separators are not allowed here. +!!! error TS6505: Numeric separators are not allowed in numbers that start with '0'. ~~~~~ !!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. ~~~~~ diff --git a/tests/baselines/reference/parser.numericSeparators.octalNegative.errors.txt b/tests/baselines/reference/parser.numericSeparators.octalNegative.errors.txt index ebdec3371aa64..74ea2a8143718 100644 --- a/tests/baselines/reference/parser.numericSeparators.octalNegative.errors.txt +++ b/tests/baselines/reference/parser.numericSeparators.octalNegative.errors.txt @@ -1,6 +1,6 @@ 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,2): error TS6505: Numeric separators are not allowed in numbers that start with '0'. 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. @@ -23,7 +23,7 @@ tests/cases/conformance/parser/ecmascriptnext/numericSeparators/6.ts(1,5): error ==== tests/cases/conformance/parser/ecmascriptnext/numericSeparators/3.ts (3 errors) ==== 0_O0101 ~ -!!! error TS6188: Numeric separators are not allowed here. +!!! error TS6505: Numeric separators are not allowed in numbers that start with '0'. ~~~~~ !!! error TS1351: An identifier or keyword cannot immediately follow a numeric literal. ~~~~~ diff --git a/tests/baselines/reference/scannerES3NumericLiteral3.errors.txt b/tests/baselines/reference/scannerES3NumericLiteral3.errors.txt deleted file mode 100644 index 51df5a9c33c3f..0000000000000 --- a/tests/baselines/reference/scannerES3NumericLiteral3.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/scanner/ecmascript3/scannerES3NumericLiteral3.ts(1,3): error TS1005: ';' expected. - - -==== tests/cases/conformance/scanner/ecmascript3/scannerES3NumericLiteral3.ts (1 errors) ==== - 01.0 - ~~ -!!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/scannerES3NumericLiteral3.js b/tests/baselines/reference/scannerES3NumericLiteral3.js index 544953a1134ac..7ecb6c8d37747 100644 --- a/tests/baselines/reference/scannerES3NumericLiteral3.js +++ b/tests/baselines/reference/scannerES3NumericLiteral3.js @@ -2,5 +2,4 @@ 01.0 //// [scannerES3NumericLiteral3.js] -01; -.0; +01.0; diff --git a/tests/baselines/reference/scannerES3NumericLiteral3.types b/tests/baselines/reference/scannerES3NumericLiteral3.types index 686e1857bfa05..a300561b59d8b 100644 --- a/tests/baselines/reference/scannerES3NumericLiteral3.types +++ b/tests/baselines/reference/scannerES3NumericLiteral3.types @@ -1,5 +1,4 @@ === tests/cases/conformance/scanner/ecmascript3/scannerES3NumericLiteral3.ts === 01.0 ->01 : 1 ->.0 : 0 +>01.0 : 1 diff --git a/tests/baselines/reference/scannerNumericLiteral3.errors.txt b/tests/baselines/reference/scannerNumericLiteral3.errors.txt deleted file mode 100644 index 894eb391f6043..0000000000000 --- a/tests/baselines/reference/scannerNumericLiteral3.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/scanner/ecmascript5/scannerNumericLiteral3.ts(1,3): error TS1005: ';' expected. - - -==== tests/cases/conformance/scanner/ecmascript5/scannerNumericLiteral3.ts (1 errors) ==== - 01.0 - ~~ -!!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/scannerNumericLiteral3.js b/tests/baselines/reference/scannerNumericLiteral3.js index 8e751bbd841b7..382c0622ac22f 100644 --- a/tests/baselines/reference/scannerNumericLiteral3.js +++ b/tests/baselines/reference/scannerNumericLiteral3.js @@ -2,5 +2,4 @@ 01.0 //// [scannerNumericLiteral3.js] -01; -.0; +01.0; diff --git a/tests/baselines/reference/scannerNumericLiteral3.types b/tests/baselines/reference/scannerNumericLiteral3.types index 0c175db8fb2ab..be53faca7abf9 100644 --- a/tests/baselines/reference/scannerNumericLiteral3.types +++ b/tests/baselines/reference/scannerNumericLiteral3.types @@ -1,5 +1,4 @@ === tests/cases/conformance/scanner/ecmascript5/scannerNumericLiteral3.ts === 01.0 ->01 : 1 ->.0 : 0 +>01.0 : 1 diff --git a/tests/baselines/reference/scannerNumericLiteral9.errors.txt b/tests/baselines/reference/scannerNumericLiteral9.errors.txt deleted file mode 100644 index 7f53ca111d981..0000000000000 --- a/tests/baselines/reference/scannerNumericLiteral9.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/scanner/ecmascript5/scannerNumericLiteral9.ts(1,3): error TS1005: ';' expected. - - -==== tests/cases/conformance/scanner/ecmascript5/scannerNumericLiteral9.ts (1 errors) ==== - 009 - ~ -!!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/scannerNumericLiteral9.js b/tests/baselines/reference/scannerNumericLiteral9.js index a391606ecdf91..bf650744ecfdc 100644 --- a/tests/baselines/reference/scannerNumericLiteral9.js +++ b/tests/baselines/reference/scannerNumericLiteral9.js @@ -2,5 +2,4 @@ 009 //// [scannerNumericLiteral9.js] -00; -9; +009; diff --git a/tests/baselines/reference/scannerNumericLiteral9.types b/tests/baselines/reference/scannerNumericLiteral9.types index f204fa0977fc2..95bb891139f0b 100644 --- a/tests/baselines/reference/scannerNumericLiteral9.types +++ b/tests/baselines/reference/scannerNumericLiteral9.types @@ -1,5 +1,4 @@ === tests/cases/conformance/scanner/ecmascript5/scannerNumericLiteral9.ts === 009 ->00 : 0 ->9 : 9 +>009 : 9 diff --git a/tests/cases/conformance/parser/ecmascriptnext/numericSeparators/parser.numericSeparators.decmialNegative.ts b/tests/cases/conformance/parser/ecmascriptnext/numericSeparators/parser.numericSeparators.decmialNegative.ts index 3c294148c19e7..c55041c24b6da 100644 --- a/tests/cases/conformance/parser/ecmascriptnext/numericSeparators/parser.numericSeparators.decmialNegative.ts +++ b/tests/cases/conformance/parser/ecmascriptnext/numericSeparators/parser.numericSeparators.decmialNegative.ts @@ -150,3 +150,9 @@ _0.0e-0 // @filename: 51.ts 0._ + +// @filename: 52.ts +09_0 + +// @filename: 53.ts +07_0