Skip to content

Commit b1f71e6

Browse files
committed
Address feedback
1 parent 0838158 commit b1f71e6

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

src/compiler/parser.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,11 @@ module ts {
10621062
if (node.kind === SyntaxKind.NumericLiteral && (isInStrictMode || languageVersion >= ScriptTarget.ES5)) {
10631063
var numberLiteralSource = getSourceTextOfNodeFromSourceText(sourceText, node);
10641064
// This regex checks if the number is written in octal
1065+
// Note that theoretically would match literals like 009, which is not octal. But because
1066+
// of how the scanner separates the tokens, we would never get a token like this. Instead,
1067+
// we would get 00 and 9 as two separate tokens.
1068+
// We also do not need to check for negatives because any prefix operator would be part of a
1069+
// parent unary expression.
10651070
if (/0[0-7]+/.test(numberLiteralSource)) {
10661071
if (isInStrictMode) {
10671072
grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
==== tests/cases/conformance/scanner/ecmascript5/scannerNumericLiteral8.ts (1 errors) ====
2+
-03
3+
~~
4+
!!! Octal literals are not available when targeting ECMAScript 5 and higher.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
==== tests/cases/conformance/scanner/ecmascript5/scannerNumericLiteral9.ts (2 errors) ====
2+
009
3+
~~
4+
!!! Octal literals are not available when targeting ECMAScript 5 and higher.
5+
~
6+
!!! ';' expected.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// @target: ES5
2+
-03
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// @target: ES5
2+
009

0 commit comments

Comments
 (0)