@@ -2153,10 +2153,6 @@ namespace Parser {
2153
2153
return currentToken = scanner.reScanTemplateToken(isTaggedTemplate);
2154
2154
}
2155
2155
2156
- function reScanTemplateHeadOrNoSubstitutionTemplate(): SyntaxKind {
2157
- return currentToken = scanner.reScanTemplateHeadOrNoSubstitutionTemplate();
2158
- }
2159
-
2160
2156
function reScanLessThanToken(): SyntaxKind {
2161
2157
return currentToken = scanner.reScanLessThanToken();
2162
2158
}
@@ -3606,9 +3602,7 @@ namespace Parser {
3606
3602
}
3607
3603
3608
3604
function parseTemplateHead(isTaggedTemplate: boolean): TemplateHead {
3609
- if (isTaggedTemplate) {
3610
- reScanTemplateHeadOrNoSubstitutionTemplate();
3611
- }
3605
+ reScanTemplateToken(isTaggedTemplate);
3612
3606
const fragment = parseLiteralLikeNode(token());
3613
3607
Debug.assert(fragment.kind === SyntaxKind.TemplateHead, "Template head has wrong token kind");
3614
3608
return fragment as TemplateHead;
@@ -3630,14 +3624,13 @@ namespace Parser {
3630
3624
const pos = getNodePos();
3631
3625
const node =
3632
3626
isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & TokenFlags.TemplateLiteralLikeFlags) :
3633
- // Octal literals are not allowed in strict mode or ES5
3634
3627
// Note that theoretically the following condition would hold true literals like 009,
3635
3628
// which is not octal. But because of how the scanner separates the tokens, we would
3636
3629
// never get a token like this. Instead, we would get 00 and 9 as two separate tokens.
3637
3630
// We also do not need to check for negatives because any prefix operator would be part of a
3638
3631
// parent unary expression.
3639
3632
kind === SyntaxKind.NumericLiteral ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) :
3640
- kind === SyntaxKind.StringLiteral ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) :
3633
+ kind === SyntaxKind.StringLiteral ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape(), scanner.getRangesOfOctalSequences() ) :
3641
3634
isLiteralKind(kind) ? factory.createLiteralLikeNode(kind, scanner.getTokenValue()) :
3642
3635
Debug.fail();
3643
3636
@@ -6314,7 +6307,7 @@ namespace Parser {
6314
6307
tag,
6315
6308
typeArguments,
6316
6309
token() === SyntaxKind.NoSubstitutionTemplateLiteral ?
6317
- (reScanTemplateHeadOrNoSubstitutionTemplate( ), parseLiteralNode() as NoSubstitutionTemplateLiteral) :
6310
+ (reScanTemplateToken(/*isTaggedTemplate*/ true ), parseLiteralNode() as NoSubstitutionTemplateLiteral) :
6318
6311
parseTemplateExpression(/*isTaggedTemplate*/ true)
6319
6312
);
6320
6313
if (questionDotToken || tag.flags & NodeFlags.OptionalChain) {
@@ -6414,10 +6407,14 @@ namespace Parser {
6414
6407
6415
6408
function parsePrimaryExpression(): PrimaryExpression {
6416
6409
switch (token()) {
6410
+ case SyntaxKind.NoSubstitutionTemplateLiteral:
6411
+ if (scanner.getTokenFlags() & TokenFlags.ContainsOctalOrInvalidEscape) {
6412
+ reScanTemplateToken(/* isTaggedTemplate */ false);
6413
+ }
6414
+ // falls through
6417
6415
case SyntaxKind.NumericLiteral:
6418
6416
case SyntaxKind.BigIntLiteral:
6419
6417
case SyntaxKind.StringLiteral:
6420
- case SyntaxKind.NoSubstitutionTemplateLiteral:
6421
6418
return parseLiteralNode();
6422
6419
case SyntaxKind.ThisKeyword:
6423
6420
case SyntaxKind.SuperKeyword:
0 commit comments