Just an FYI, bug report to proper issue tracker, just wanted to make community 
aware (and tell me if there's something I'm missing!)

Billy Cravens
[email protected]



On Dec 29, 2011, at 11:57 AM, Billy Cravens wrote:

> In some of my CFC's, I define my functions in script (since I've written 
> script-based CFCs in Railo/ACF, quickest port was to wrap in <cfscript> and 
> <cfcomponent>)
> 
> Noticed some odd behavior when my function has multiple params with defaults, 
> and I explicitly set a value other than the first param.
> 
> 
> Code for reference:
> 
> obj.cfc:
> <cfcomponent>
> <cfscript>
> function foo(a=1,b=2,c=3) {
>       writedump(arguments); // contrived little example
> }
> </cfscript>
> </cfcomponent>
> 
> test.cfm:
> <cfscript>
> myObj = new obj();
> myObj.foo();
> myObj.foo(a=4); // works correctly
> myObj.foo(b=4); // a disappears, and b unchanged!
> myObj.foo(c=4); // a disappears and c unchanged!
> myObj.foo(b=4,c=5); // a disappears and c unchanged - but b works?
> myObj.foo(c=5, b=4); // despite reversed order, same result as last line
> </cfscript>
> 
> When you explicitly set the value of anything other than the first param, it 
> loses the first param, and no arguments change. However, if you set more than 
> one value, it seems that only the last argument doesn't change (first param 
> still missing).
> 
> Confirmed that it behaves correctly if you use <cffunction> based methods. I 
> can't replicate this bug in UDF's, only CFCs. Bug seems to exist whether 
> you're in a method or an implicit constructor (function name init(), 
> arguments in new invocation) - I actually discovered this when I added a 
> second param to one of my constructors.
> 
> The obvious solution is to switch to all <cffunction> methods, but this is 
> still a pretty big core bug, IMO.
> 
> 
> Billy Cravens
> [email protected]
> 
> 
> 

-- 
online documentation: http://openbd.org/manual/
   google+ hints/tips: https://plus.google.com/115990347459711259462
     http://groups.google.com/group/openbd?hl=en

Reply via email to