tracker issue : CF-3842517

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

Error when trying to loop (cfloop) over an empty array that is created implicitly and passed to (as an argument) - returned from a function.

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Rajesh Brukol / Rajesh Brukol (TwR)

Created: 10/23/2014

Components: Core Runtime

Versions: 11.0

Failure Type: Crash

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Linux

Vote Count: 1

Listed in the version 2016.0.0.297996 Issues Fixed doc
Verification notes: verified_fixed on August 06, 2017 using build 2016.0.01.298513
Problem Description:
There is an error when trying to loop (cfloop) over an empty array that is created implicitly and passed to (as an argument) - returned from a function.

Steps to Reproduce:
Try this code:
<cffunction name="foo">
    <cfargument name="ar" >
    <cfreturn arguments.ar>
</cffunction>

<cfloop array="#foo([])#" index="i">
    <cfoutput>Array : #i# <br /></cfoutput>
</cfloop>

Actual Result:
error
Error type : coldfusion.runtime.CfErrorWrapper
Diagnostic : Variable ___IMPLICITARRYSTRUCTVAR3 is undefined. 

Expected Result:
empty loop but no error

Any Workarounds:
change foo([]) to foo(ArrayNew(1))

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

Watson Bug ID:	3842517

External Customer Info:
External Company:  
External Customer Name: TwR
External Customer Email:  
External Test Config: cf11

Attachments:

Comments:

We are checking the possibility to migrate our CF9 app to CF11. We have a function like this: function getDataFromConfig(required string settingName, required any defaultValue){ if(check_if_there_is_a_value_for_given_settingName){ return value_from_config; }else{ return arguments.defaultValue; } } It's usually used with empty array as a default like this: getDataFromConfig("some_name",[]); when used in a loop this causes an error under CF11 temp fix would be to use it like this: getDataFromConfig("some_name",ArrayNew(1)) ;
Comment by External U.
10508 | October 23, 2014 04:07:09 AM GMT
+1 ......................
Vote by External U.
10510 | November 26, 2014 03:49:01 AM GMT
Verified this is fixed in CF2016 Update 1 (build 2016.0.01.298513). Thanks!, -Aaron
Comment by Aaron N.
10509 | August 06, 2017 12:15:51 AM GMT