Incorrect interpretation of FutureReservedWords in sloppy mode

NEW
Unassigned

Status

()

4 years ago
a year ago

People

(Reporter: jugglinmike, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

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               
    false
    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 ....^

Justification:
- ES5 - 7.6.1.2 Future Reserved Words - https://es5.github.io/#x7.6.1.2
- ES6 - 12.1.1 Static Semantics: Early Errors - https://people.mozilla.org/~jorendorff/es6-draft.html#sec-identifiers-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>
    <script>
      var yield;
      console.log("pass");
    </script>

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.