Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b1f71e6

Browse filesBrowse files
committed
Address feedback
1 parent 0838158 commit b1f71e6
Copy full SHA for b1f71e6

5 files changed

+19Lines changed: 19 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/compiler/parser.ts‎

Copy file name to clipboardExpand all lines: src/compiler/parser.ts
+5Lines 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);
Collapse file
+4Lines 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.
Collapse file
+6Lines 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.
Collapse file
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// @target: ES5
2+
-03
Collapse file
+2Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.