tracker issue : CF-3791747

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

each() does not support ordered arguments

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

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

Created: 07/19/2014

Components: Language

Versions: 11.0

Failure Type:

Found In Build/Fixed In Build: CF11_Final / CF11 Update5

Priority/Frequency: Major / Some users will encounter

Locale/System: ALL / Platforms All

Vote Count: 1

Listed in the version Issues Fixed doc
See here:

// eachBug.cfm

iterateArgs = function(){

iterateArgs("tahi", "rua", "toru", "wha");

Outputs the arguments in a "random" order. It should be ordered. That's what ordered arguments mean... they have a sense of order.

I suspect you are just using the struct version of the each() function, rather than working out how the args have been passed (which is significant, here).

Railo gets this right, btw.


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

Watson Bug ID:	3791747

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



Arguments scope is not an array. It is a struct and there is no order maintained for the struct. So why is this a bug with "each"? "each" works on the struct and iterates over it.
Comment by Rupesh K.
11571 | August 18, 2014 10:24:11 PM GMT
Run this version of the code and get back to me about arguments not being an array, Rupesh: <cfscript> iterateArgs = function(){ writeOutput(arguments[1] & "<br>"); writeOutput(arguments[2] & "<br>"); writeOutput(arguments[3] & "<br>"); writeOutput(arguments[4] & "<br>"); a = []; st = {}; writeOutput("Array: #a.getClass().getName()#<br>"); writeOutput("Struct: #st.getClass().getName()#<br>"); writeOutput("arguments: #arguments.getClass().getName()#<br>"); arguments.each(function(){ writeDump(var=arguments); }); }; iterateArgs("tahi", "rua", "toru", "wha"); </cfscript> The arguments scope is neither an array nor a struct, it's a hybrid which effects both struct-like and array-like behaviour. It DOES maintain the order of its collection, so it stands to reason this is reflected when iterating over it. But you already know all this, don't you, Rupesh, so I kinda wonder why you're making me tell you? -- Adam
Comment by External U.
11572 | August 19, 2014 12:40:55 AM GMT
+1 - argumentArray's order should be honored
Vote by External U.
11578 | November 16, 2014 02:57:40 AM GMT
Can we pls get details of the fix, and estimated release timeframe?
Comment by External U.
11573 | January 28, 2015 03:50:22 AM GMT
Adam, We will ship this fix in the subsequent hotfix for CF11.
Comment by Suchika S.
11574 | January 28, 2015 03:53:38 AM GMT
Right, cheers. That answers the second part of the sentence. What about the first part? I ask because given the arguments scope is a hybrid array/struct, then the solution here will be a non-standard one which might require more thought than... sometimes bug solutions have applied to them. So before you push something out the door, I'd like to check what you've done and whether it's actually a decent, well-thought-out solution.
Comment by External U.
11575 | January 28, 2015 03:56:10 AM GMT
The fix for this bug is available in the pre-release build of ColdFusion 11 Update 5
Comment by CFwatson U.
11576 | February 20, 2015 09:26:22 AM GMT
Confirmed fixed, cheers.
Comment by External U.
11577 | February 21, 2015 08:02:40 PM GMT