Closed Bug 883468 Opened 11 years ago Closed 10 years ago

ES6 Comprehension syntax is different

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 979865

People

(Reporter: bbenvie, Unassigned)

References

(Blocks 1 open bug)

Details

The syntax for Array Comprehensions in ES6 is different from what's implemented in SpiderMonkey. The AssignmentExpression now comes at the end of comprehension, instead of the beginning.

SpiderMonkey:
> [x for (x of iter) if (cond)]

ES6
> [for (x of iter) if (cond) x]


See ES6 draft spec section 11.1.4.2.

Reference: https://github.com/rwldrn/tc39-notes/blob/master/es6/2013-01/jan-31.md#comprehensionsgenerator-syntax
Summary: ES6 Array Comprehension syntax is different → ES6 Array/Generator Comprehension syntax is different
Summary: ES6 Array/Generator Comprehension syntax is different → ES6 Comprehension syntax is different
This applies to both Generator and Array Comprehensions.
Ooh, can we get rid of that arrayComprehensionTail "I thought this parse tree was in this function, but really it's in this other function" craziness?
I was just reviewing the Set docs (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) and there was an example that used the obsolete syntax to illustrate an intersection operation with new Set(initializer). I've updated the example and added a note explaining SpiderMonkey syntax is incorrect. 

cc Andy Wingo
Is this a DUP of bug 979865 ?
(In reply to David Bruant from comment #4)
> Is this a DUP of bug 979865 ?

Indeed.  I did search for dups, but it seems my keyword-fu is weak :P
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.