mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Added error for IdentifierStart immediately after a NumericLiteral
Fixes #4702.
This commit is contained in:
@@ -1011,6 +1011,10 @@
|
||||
"category": "Message",
|
||||
"code": 1350
|
||||
},
|
||||
"An identifier cannot follow a numeric literal.": {
|
||||
"category": "Error",
|
||||
"code": 1351
|
||||
},
|
||||
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
|
||||
@@ -974,7 +974,10 @@ namespace ts {
|
||||
else {
|
||||
result = text.substring(start, end); // No need to use all the fragments; no _ removal needed
|
||||
}
|
||||
|
||||
checkForIdentifierAfterNumericLiteral();
|
||||
if (decimalFragment !== undefined || tokenFlags & TokenFlags.Scientific) {
|
||||
checkForIdentifierAfterNumericLiteral();
|
||||
return {
|
||||
type: SyntaxKind.NumericLiteral,
|
||||
value: "" + +result // if value is not an integer, it can be safely coerced to a number
|
||||
@@ -983,10 +986,17 @@ namespace ts {
|
||||
else {
|
||||
tokenValue = result;
|
||||
const type = checkBigIntSuffix(); // if value is an integer, check whether it is a bigint
|
||||
checkForIdentifierAfterNumericLiteral();
|
||||
return { type, value: tokenValue };
|
||||
}
|
||||
}
|
||||
|
||||
function checkForIdentifierAfterNumericLiteral() {
|
||||
if (isIdentifierStart(text.charCodeAt(pos), languageVersion)) {
|
||||
error(Diagnostics.An_identifier_cannot_follow_a_numeric_literal, pos, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function scanOctalDigits(): number {
|
||||
const start = pos;
|
||||
while (isOctalDigit(text.charCodeAt(pos))) {
|
||||
|
||||
Reference in New Issue
Block a user