tracker issue : CF-3041479

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

Bug 82955:-(Watson Migration Closure)Error when calling a function with an implicit struct argument containing a complex value inside a loop

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Tony Nelson / Tony Nelson (tonynelson19)

Created: 05/19/2010

Components: Language

Versions: 9.0

Failure Type:

Found In Build/Fixed In Build: 0000 / 280730

Priority/Frequency: Normal / Some users will encounter

Locale/System: English / Win All

Vote Count: 7

Problem:

Error when calling a function with an implicit struct argument containing a complex value inside a loop. This error also seems to bypass error handling (see Scenario 4), which is why I marked the severity as no known workaround instead of benign.
Method:

<!--- Here's some sample code to reproduce the issue. To test, remove the comments from around each scenario --->
<!--- create a simple array of users --->
<cfset users = [] />
<cfset users[1] = { name = "Tony Nelson" } />
<cfset users[2] = { name = "Ray Camden" } />
<cfoutput>
<!---Scenario 1: Pass in the user. This should work. 
<br />
<cfloop array="#users#" index="user">#sayHelloSimple(user)# <br />
</cfloop>--->

<!--Scenario 2: Pass in a struct containing the user. First create the struct, then pass the struct to the function. This should work. <br />
<cfloop array="#users#" index="user">
<cfset parameters = { user = user } />
#sayHelloComplex(parameters)# <br />
</cfloop>--->

Scenario 3: Pass in a struct containing the user. Rather than creating the struct first, create an implicit struct inside the function call.  This should work, but doesn't. 
<br />
<cfloop array="#users#" index="user">
     #sayHelloComplex({ user = user })# <br />
</cfloop>

<!---Scenario 4: Same as Scenario 4, but wrapped inside a try/catch. This should print "fail", but it doesn't. It appears as if the error handling is ignored. 
<br />

<cfloop array="#users#" index="user">
    <cftry>#sayHelloComplex({ user = user })# <br />
<cfcatch type="any">fail <br /></cfcatch>
</cftry>
</cfloop>--->

<!---Scenario 5: Pass in a single implicit struct containing the user without looping. This should work.  It seems like the error is partially caused by the loop creating the user variable in the previous examples. 
<br />#sayHelloComplex({ user = users[1] })# <br />--->

<!---Scenario 6: Pass in an implicit struct containing the user inside an include. This should work. Aside from the include, this code is identical to Scenario 3, which fails. It seems like the variables are handled properly after they're passed to the included template.<br />

<cfloop array="#users#" index="user">
<cfinclude template="user.cfm" />

<!--- content from user.cfm: 
   <cfoutput>#sayHelloComplex({ user = user })# <br /></cfoutput> --->

</cfloop>---></cfoutput>
<cffunction name="sayHelloSimple" returntype="string">
<cfargument name="user" type="any" />
<cfreturn "Hello, #arguments.user.name#" />
</cffunction>

<cffunction name="sayHelloComplex" returntype="string">
<cfargument name="collection" type="struct" />
<cfreturn "Hello, #arguments.collection.user.name#" />
</cffunction>
Result:

Variable XXX is undefined.

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

Watson Bug ID:	3041479

Deployment Phase:	Release Candidate

External Customer Info:
External Company:  
External Customer Name: Tony Nelson
External Customer Email: 29E2158A45C91A06992015C2
External Test Config: 05/19/2010

Attachments:

Comments: