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:
Or:
You’re just gonna have to do something like that until Adobe gets around to fixing it 🙁