Closed
Bug 1032150
Opened 10 years ago
Closed 8 years ago
Using "let" and "yield" as (Binding)Identifiers should only be a SyntaxError in strict code
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: Swatinem, Unassigned)
References
Details
While "yield" is defined as a keyword, it is explicitly allowed as identifier in "some contexts" (see http://people.mozilla.org/~jorendorff/es6-draft.html#sec-keywords) http://people.mozilla.org/~jorendorff/es6-draft.html#sec-identifiers-static-semantics-early-errors also states that "let" is only a reserved keyword in strict code. Currently both fail when using them as identifiers: ``` js> let = 10 typein:1:4 SyntaxError: missing variable name: typein:1:4 let = 10 typein:1:4 ....^ js> yield = 10 typein:2:0 SyntaxError: yield not in function: typein:2:0 yield = 10 typein:2:0 ^ ``` In nodejs (v8), using yield works fine, but they throw a SyntaxError for "let" as well ``` > yield = 10 10 > let = 10 SyntaxError: Illegal let declaration outside extended mode ```
Reporter | ||
Comment 1•10 years ago
|
||
Same goes for "eval" and "arguments" when being used as BindingIdentifiers.
Summary: Using "let" and "yield" as identifiers should only be a SyntaxError in strict code → Using "let", "yield", "eval" and "arguments" as (Binding)Identifiers should only be a SyntaxError in strict code
Reporter | ||
Comment 2•10 years ago
|
||
I’m fixing "eval" and "arguments" in destructuring in bug 933276.
Blocks: spread-assignment
Summary: Using "let", "yield", "eval" and "arguments" as (Binding)Identifiers should only be a SyntaxError in strict code → Using "let" and "yield" as (Binding)Identifiers should only be a SyntaxError in strict code
Updated•10 years ago
|
Keywords: dev-doc-needed
Whiteboard: [DocArea=JS]
Updated•9 years ago
|
Comment 3•8 years ago
|
||
Threading YieldHandling through the entire parser in bug 1155472 should have, I believe, fixed the issue of |yield| as identifier. (1.7-versioned code does still have legacy generators, but non-standard code can do non-standard things -- as long as non-versioned normal code does the right thing, I think we handle |yield| correctly per this bug's complaint.) And re |let|, I think bug 1233249 fixed the bug that you could declare let/const variables named |let|. That's the last remaining let/const identifier bug I'm aware of. So I'm going to mark this fixed. Let's file any remaining issues in new bugs, with the issue precisely marked. (Then we won't be in a situation again of having an open bug, that we can't easily identify as still a problem or no longer a problem.)
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Updated•8 years ago
|
Keywords: dev-doc-needed
Whiteboard: [DocArea=JS]
You need to log in
before you can comment on or make changes to this bug.
Description
•