For consistency with destructuring assignment, the following algorithms should be changed to throw a TypeError instead of performing ToObject():
11.1.4.2 Array Comprehension
Runtime Semantics: Binding Initialisation
- step 1 uses ToObject()
12.6.4.2 Runtime Semantics
Runtime Semantics: For In/Of Expression Evaluation Abstract Operation
- step 3.h.iii.2 uses ToObject()
12.14.2 Runtime Semantics
Runtime Semantics: Binding Initialisation
- step 1 uses ToObject()
For example `for (var [head, ...tail] of ["123"]) {print(tail)}` currently prints "2,3" whereas the similar assignment `var [head, ...tail] = "123"` throws a TypeError.
rev19 update: ToObject() removed from
- 13.6.4.7 Runtime Semantics: ForIn/OfBodyEvaluation
- 13.14.3 Runtime Semantics: BindingInitialisation
That means only "12.1.4.2.2 Runtime Semantics: BindingInitialisation" still calls ToObject() in a destructuring context.
fixed in rev20 editor's draft
fixed in rev20 draft, Oct. 28, 2013