Early error on '0' followed by '8' or '9' in numeric literals does not seem to be web-compatible

Mathias Bynens mathias at qiwi.be
Tue Aug 5 00:03:25 PDT 2014

On 4 Aug 2014, at 18:55, Jason Orendorff <jason.orendorff at gmail.com> wrote:

> We're talking about something different here, legacy *decimal* integer
> literals starting with 0 and containing 8 or 9. As far as I know, no
> version of ES has ever permitted this kind of nonsense, but supporting
> it is apparently required for Web compatibility. (One more great
> reason to write all your code under "use strict".)

I don’t understand this comment. What does strict mode have to do with this? Note that `08` and `09` are not octal literals, since `8` and `9` are not `OctalDigit`s.

In non-strict mode, https://people.mozilla.org/~jorendorff/es6-draft.html#sec-additional-syntax-numeric-literals applies, but even then `08` and `09` should throw (as per the current spec) for the same reason.

Strict mode doesn’t make a difference as per the current spec when parsing this program:


It does in Firefox/Spidermonkey, but that seems like a bug. Test this in the most recent nightly:

(function() { 'use strict'; return 08; }())

This currently throws:

> SyntaxError: octal literals and octal escape sequences are deprecated

…which is a misleading message. It should instead say something like:

> SyntaxError: numbers starting with 0 followed by a digit are octals and can't contain 8

More information about the es-discuss mailing list