Closed Bug 345736 Opened 19 years ago Closed 19 years ago

"for each" and "let[x,y]" in array comprehensions

Categories

(Core :: JavaScript Engine, enhancement)

enhancement
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: bugzilla, Assigned: brendan)

References

Details

(Keywords: verified1.8.1)

Attachments

(2 files)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1b1) Gecko/20060724 BonEcho/2.0b1 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1b1) Gecko/20060724 BonEcho/2.0b1 Suppose you execute the following in Firefox 2.0: arr=[x+x for (x in ["a","b","c"])]; Now arr contains ["00","11","22"] Wanting to get a result like ["aa","bb","cc"], I try both of the following: arr=[x+x for each (x in ["a","b","c"])]; arr=[x+x for (let [,x] in ["a","b","c"])]; But neither syntax is valid in array comprehensions, even though both are supported in for() loops. Supporting either of those would make JS 1.7's array comprehension support more python-like. Reproducible: Always
Assignee: nobody → general
Component: General → JavaScript Engine
Product: Firefox → Core
QA Contact: general → general
Version: unspecified → Trunk
The destructuring assignment in comprehensions work is being tracked in bug 336379, but I'll take this one and make it depend on the js1.7 metabug. /be
Assignee: general → brendan
Blocks: js1.7
Status: UNCONFIRMED → NEW
Ever confirmed: true
Small patch (diff -w coming), needed for js1.7. /be
Status: NEW → ASSIGNED
Flags: blocking1.8.1?
Attached patch fixSplinter Review
diff -w version next. /be
Attachment #232025 - Flags: review?(mrbkap)
Attachment #232025 - Flags: review?(mrbkap) → review+
Attachment #232025 - Flags: approval1.8.1?
Fixed on trunk. /be
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Comment on attachment 232025 [details] [diff] [review] fix a=schrep for drivers.
Attachment #232025 - Flags: approval1.8.1? → approval1.8.1+
Fixed on the 1.8 branch too. /be
Keywords: fixed1.8.1
Checking in regress-345736.js; /cvsroot/mozilla/js/tests/js1_7/geniter/regress-345736.js,v <-- regress-345736.js initial revision: 1.1 tests for [x+x for (x in ["a","b","c"])]; [x+x for each (x in ["a","b","c"])];
Flags: in-testsuite+
verified fixed 1.8, 1.9 win/mac(ppc|tel)/linux 20060808
Status: RESOLVED → VERIFIED
Flags: blocking1.8.1?
There should be regression tests for the destructuring-like form, too. js> arr=[x+x for ([,x] in ["a","b","c"])]; aa,bb,cc js> arr=[x+y for ([x,y] in ["a","b","c"])]; 0a,1b,2c
Flags: in-testsuite+ → in-testsuite?
/cvsroot/mozilla/js/tests/js1_7/geniter/regress-345736.js,v <-- regress-345736.js new revision: 1.2; previous revision: 1.1 done
Flags: in-testsuite? → in-testsuite+
No longer depends on: 409757
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: