Closed Bug 1146532 Opened 10 years ago Closed 6 years ago

Incorrect interpretation of FutureReservedWords in sloppy mode

Categories

(Core :: JavaScript Engine, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: jugglinmike, Unassigned)

References

(Blocks 1 open bug)

Details

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: 1JS
Depends on: 1192329
No longer depends on: 1JS
Blocks: test262
WFM now. I imagine I could dig up what fixed this, but the reality is it isn't worth it. [jwalden@find-waldo-now src]$ dbg/js/src/js js> var yield; js> var let; js> [jwalden@find-waldo-now src]$ dbg/js/src/js js> "use strict"; var yield; typein:1:18 SyntaxError: yield is a reserved identifier: typein:1:18 "use strict"; var yield; typein:1:18 ..................^ js> "use strict"; var let; typein:2:18 SyntaxError: let is a reserved identifier: typein:2:18 "use strict"; var let; typein:2:18 ..................^
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.