« Bugzilla Issues Index

#381 — Generator comprehension and array comprehension should use ForBinding instead of LeftHandSideExpression

The draft currently have:

ComprehensionFor :
for LeftHandSideExpression of Expression

This leads to the following being allowed:

(a for b.c of d)

What is the intention of allowing LeftHandSideExpression above? Who is responsible for creating the bindings here?

If we change ComprehensionFor to use a ForBinding it is clearer where the bindings come from.

ComprehensionFor :
for ForBinding of Expression

Are you looking at an old draft. My draft has ForBinding in that spot and and says that change was made 4/12/12. It should be in the 5/4 draft. Also I new draft will probably go out on 6/15

5/4 draft has ForBinding for Array Comprehension but not for Generator

11.1.7 Generator Comprehensions


GeneratorComprehension :
( Expression ComprehensionForList )
( Expression ComprehensionForList if ( Expression ) )

ComprehensionForList :
ComprehensionForList ComprehensionFor

ComprehensionFor :
for LeftHandSideExpression of Expression

Ah, the generator productions are redundant and I'll delete them. Although, they might come back when I do the semantics