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)

defect
Not set
normal

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.
See Also: → 1095439
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.
Assignee: nobody → evilpies
Apparently they decided to make this a runtime error, again?!
Assignee: evilpies → nobody
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
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
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.