Unusual error with named arguments and implicit structure creation when calling a function

Here is a really weird bug I recently encountered in CF9. Does anyone know why this is happening and if I am doing something wrong or a fix is ​​available. Take a look at the following code. We take a line, add A, add B, and then try to add C ... but the result we get is "ababc". Expected Result: "abc". The error occurs only if you execute the named argument AND and the implicit struct in argument pass AND a &= in the function call. If any of these three cases does not exist, an error does not occur. Any ideas why?

 <cffunction name="test"> <cfargument name="widget"> <cfset var locals = StructNew()> <cfreturn arguments.widget.value> </cffunction> <cfset return = ""> <cfset return &= "a"> <cfset return &= "b"> <cfset return &= test(widget = { value = "c" })> <cfoutput>#return#</cfoutput> 
+8
coldfusion coldfusion-9
source share
1 answer

Good: you answered your own question here: this is because it is a mistake. Errors occur. Good thing you took the time to advise Adobe about this.

As for working around, these two options work fine:

 <cfset return = ""> <cfset return &= "a"> <cfset return &= "b"> <cfset st = { value = "c" }><!--- refactor where the struct is created ---> <cfset return &= test(widget = st)> <cfoutput>#return#</cfoutput> 

Or:

 <cfset return = ""> <cfset return &= "a"> <cfset return &= "b"> <cfset temp = test(widget = { value = "c" })><!--- refactor where the function is called ---> <cfset return &= temp> <cfoutput>#return#</cfoutput> 

You just need to do something similar until Adobe proceeds to fix it: - (

+2
source share

All Articles