Here's a really bizarre bug I recently ran across in CF9. Anyone have a clue why it is occurring and if either I am doing something wrong, or there is a hotfix available. Look at the following code. We take a string, add an A, add a B, and then attempt to add a C... yet the result we get is "ababc". The expected result is "abc". The bug only occurs if you do a named argument AND an implicit struct in argument pass AND a &=
operator in the function call. If any of those 3 cases is not there, the bug 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>
Well: you've kinda answered your own question here: it happens because it's a bug. Bugs happen. It's good you've taken the time to advise Adobe about it.
As for work arounds, these two variations 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're just gonna have to do something like that until Adobe gets around to fixing it :-(
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With