Closed Bug 901987 Opened 6 years ago Closed 6 years ago

for-of loops do not accept initialisers and are restricted to assignment expressions

Categories

(Core :: JavaScript Engine, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla30

People

(Reporter: anba, Assigned: wingo)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

The following for-of loops should both throw a SyntaxError:
---
for (var v=0 of [1]) print(v)
for (var v of [1],[2],[3]) print(v)
---

(1) for-of loops do not accept an initialiser expression
(2) for-of loops only allow assignment expressions as their RHS
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee: general → wingo
I should note that the first part of this bug is already fixed and tested by jit-test for-of/syntax-3.js.
Comment on attachment 8388411 [details] [diff] [review]
The RHS of a for-of loop is an assignment expression

Review of attachment 8388411 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks.
Attachment #8388411 - Flags: review?(jorendorff) → review+
https://hg.mozilla.org/mozilla-central/rev/39f411171c6f
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla30
You need to log in before you can comment on or make changes to this bug.