Address feedback

This commit is contained in:
Jason Freeman 2014-08-07 12:08:31 -07:00
parent 083815893b
commit b1f71e6504
5 changed files with 19 additions and 0 deletions

View file

@ -1062,6 +1062,11 @@ module ts {
if (node.kind === SyntaxKind.NumericLiteral && (isInStrictMode || languageVersion >= ScriptTarget.ES5)) {
var numberLiteralSource = getSourceTextOfNodeFromSourceText(sourceText, node);
// This regex checks if the number is written in octal
// Note that theoretically would match literals like 009, which is not octal. But because
// of how the scanner separates the tokens, we would never get a token like this. Instead,
// we would get 00 and 9 as two separate tokens.
// We also do not need to check for negatives because any prefix operator would be part of a
// parent unary expression.
if (/0[0-7]+/.test(numberLiteralSource)) {
if (isInStrictMode) {
grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode);

View file

@ -0,0 +1,4 @@
==== tests/cases/conformance/scanner/ecmascript5/scannerNumericLiteral8.ts (1 errors) ====
-03
~~
!!! Octal literals are not available when targeting ECMAScript 5 and higher.

View file

@ -0,0 +1,6 @@
==== tests/cases/conformance/scanner/ecmascript5/scannerNumericLiteral9.ts (2 errors) ====
009
~~
!!! Octal literals are not available when targeting ECMAScript 5 and higher.
~
!!! ';' expected.

View file

@ -0,0 +1,2 @@
// @target: ES5
-03

View file

@ -0,0 +1,2 @@
// @target: ES5
009