From 60417ff37966b74b416d3cb21179cbb68f7e529d Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 20 Nov 2014 13:44:51 -0800 Subject: [PATCH] save token in scanner after scaning hex literal --- src/compiler/scanner.ts | 4 ++-- tests/cases/fourslash/formattingHexLiteral.ts | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 tests/cases/fourslash/formattingHexLiteral.ts diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index e08f481ba9c..4858265932e 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -931,12 +931,12 @@ module ts { value = 0; } tokenValue = "" + value; - return SyntaxKind.NumericLiteral; + return token = SyntaxKind.NumericLiteral; } // Try to parse as an octal if (pos + 1 < len && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - return SyntaxKind.NumericLiteral; + return token = SyntaxKind.NumericLiteral; } // 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 diff --git a/tests/cases/fourslash/formattingHexLiteral.ts b/tests/cases/fourslash/formattingHexLiteral.ts new file mode 100644 index 00000000000..a3cb1a3e16c --- /dev/null +++ b/tests/cases/fourslash/formattingHexLiteral.ts @@ -0,0 +1,5 @@ +/// + +////var x = 0x1,y; + +format.document(); // should not crash