Incorrect interpretation of FutureReservedWords in sloppy mode




4 years ago
a year ago


(Reporter: jugglinmike, Unassigned)


Firefox Tracking Flags

(Not tracked)




4 years ago
When used as identifiers, some tokens should *only* produce errors in strict mode code. In SpiderMonkey today, using `yield` and `let` as identifiers incorrectly produces errors:

    js> (function() { return this; })() === undefined               
    js> var yield;
    typein:6:4 SyntaxError: yield is a reserved identifier:
    typein:6:4 var yield;
    typein:6:4 ....^
    js> var let;
    typein:7:4 SyntaxError: missing variable name:
    typein:7:4 var let;
    typein:7:4 ....^

- ES5 - Future Reserved Words -
- ES6 - 12.1.1 Static Semantics: Early Errors -
Yeah. This is a side effect of a deeper, weirder problem. The good news is, if you put this in a file and open it in Firefox:

    <!DOCTYPE html>
      var yield;

you'll see "pass" in the console, meaning there was no SyntaxError.

The deeper problem is bug 867609: SM implements two variants of JS. There's the standard, Web-compatible version; and the nonstandard version used for Firefox implementation code and addons. The latter contains several features (like legacy generators) that were once desirable, but are now obsoleted by ES6.

We want to change it, but for now this nonstandard dialect is the default both for the JS shell (bug 1192329) and the devtools console (bug 1173883).
Depends on: 867609
Depends on: 1192329
No longer depends on: 867609
You need to log in before you can comment on or make changes to this bug.