Closed
Bug 1094995
Opened 11 years ago
Closed 8 years ago
for (const ... in/of ...) should work, binding a fresh set of const variables each iteration
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: efaust, Unassigned)
References
Details
ziyunfei points out:
> js> const x = undefined;for (x of [1,2,3])print(x);
> typein:2:25 SyntaxError: invalid for/in left-hand side:
> typein:2:25 const x = undefined;for (x of [1,2,3])print(x);
> typein:2:25 .........................^
> js>
> js> const x = undefined;
> js> for (x of [1,2,3])print(x); // Should this throw an error?
> undefined
> undefined
> undefined
This is crazed. ES6 10/14/14 13.6.4.1 forbids this nonsense.
Comment 1•11 years ago
|
||
This was fixed by bug 1095439. I am however going to re-purpose this bug to add this testcase and change for (const x .. ) to a SyntaxError.
Updated•11 years ago
|
Assignee: nobody → evilpies
Comment 2•11 years ago
|
||
Apparently they decided to make this a runtime error, again?!
Updated•11 years ago
|
Assignee: evilpies → nobody
Updated•10 years ago
|
Summary: for-in and for-of only reject const LHS if it's declared in the for head. → for (const ... in/of ...) should work, binding a fresh set of const variables each iteration
Comment 3•9 years ago
|
||
`for (const x ...)` is valid, not a syntax error.
See test ES6 spec test case https://github.com/tc39/test262/blob/1c1a75eead413ab5152e825d3c551908667e405f/test/language/statements/for-in/const-fresh-binding-per-iteration-for-in.js#L10
Comment 4•9 years ago
|
||
Once I've fixed bug 449811 and/or bug 1069480 and/or some other bug in a massive bug-confluence that I intend to fix approximately all at once, this should be a few-line change in the parser, only. That work is In Progress as we speak.
Depends on: 449811
Comment 6•8 years ago
|
||
This got fixed in the parser rewrite, don't remember what bug number to use for dup/dependency, not important.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•