Status: New
Owner: ----

New issue 1954 by [email protected]: Octal escape sequences (octal literals) with less than three digits should throw a SyntaxError in strict mode
http://code.google.com/p/v8/issues/detail?id=1954

I was reviewing http://mathiasbynens.be/notes/javascript-escapes when I came across this bug.

Octal escapes (aka. octal literals) have been deprecated in ES5. See http://es5.github.com/B.html#B.1:

Past editions of ECMAScript have included additional syntax and semantics
for specifying octal literals and octal escape sequences. These have been
removed from this edition of ECMAScript. This non-normative annex presents
uniform syntax and semantics for octal literals and octal escape sequences
for compatibility with some older ECMAScript programs.

Additionally, they produce syntax errors in strict mode. See http://es5.github.com/C.html#C:

A conforming implementation, when processing strict mode code (see 10.1.1),
may not extend the syntax of `EscapeSequence` to include
`OctalEscapeSequence` as described in B.1.2.

It seems v8 does this correctly for octal literals with exactly three digits, e.g. `\000`:

    (function() { "use strict"; console.log("\000"); }());
    // SyntaxError: Octal literals are not allowed in strict mode.

For octal literals with less than three digits, e.g. `\0` (which is equal to `\000`), it doesn’t error:

    (function() { "use strict"; console.log("\0"); }());
    // no error is thrown

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to