tracker issue : CF-3864256

select a category, or use search below
(searches all categories and all time range)

Array for-in loop is broken for sparse arrays

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)

Created: 12/08/2014

Components: Language

Versions: 9.0

Failure Type:

Found In Build/Fixed In Build: 9.0 /

Priority/Frequency: Major / Some users will encounter

Locale/System: ALL / Platforms All

Vote Count: 2

Listed in the version 2016.0.0.297996 Issues Fixed doc
Verification notes: verified_fixed on August 25, 2019 using build 2016.0.01.298513

<cfset a = arrayNew(1)>
<cfset a[1] ="a">
<cfset a[3] = "c">

<cfloop index="e" array="#a#">

for (e in a){

Tag version works fine; script version errors with:

Variable E is undefined.

Both should work the same.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3864256


External Customer Info:
External Company:  
External Customer Name: Adam Cameron.
External Customer Email:  
External Test Config: My Hardware and Environment details:



Oh, it's also broken in CF11, so presume it needs fixing in all current versions of CF (that being 9, 10, 11 at time of writing).
Comment by External U.
9595 | December 08, 2014 01:16:55 PM GMT
+1 ......................
Vote by External U.
9598 | January 06, 2015 02:53:30 AM GMT
Vote must be between 25 and 4000 characters
Vote by External U.
9599 | January 15, 2015 07:36:34 AM GMT
Fixed in which build, pls?
Comment by External U.
9596 | June 18, 2015 05:20:15 AM GMT
The fix will be available with the next release
Comment by Immanuel N.
9597 | June 19, 2015 04:36:45 AM GMT
Hi all, I need to retract my 01/06/2015 vote, b/c the fix for this ticket didn't resolve CF's inconsistency of looping sparse arrays. I've filed CF-4205055 to resolve CF's inconsistency of looping sparse arrays. Thanks!, -Aaron
Comment by Aaron N.
31166 | August 23, 2019 11:57:02 PM GMT
Hi Adobe, I've verified this is fixed in CF2016 Update 1 (build 2016.0.01.298513). However, IMO, the tag version was correct and the for-in should've been changed to match the tag version. What CF has now is a worse (instead of solved) inconsistency in how its looping constructs handle sparse arrays. Please see CF-4205055 for details. Thanks!, -Aaron
Comment by Aaron N.
31191 | August 25, 2019 02:15:00 AM GMT