tracker issue : CF-3038002

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

Bug 76181:(Watson Migration Closure)Optional arguments still show up in the arguments scope, but as undefined values (they're null)

| View in Tracker

Status/Resolution/Reason: Closed/Won't Fix/LowImpact

Reporter/Name(from Bugbase): Elliott Sprehn / Elliott Sprehn (Elliott Sprehn)

Created: 03/25/2009

Components: Language

Versions: 9.0

Failure Type: Unspecified

Found In Build/Fixed In Build: 0000 /

Priority/Frequency: Normal / Unknown

Locale/System: English / Platforms All

Vote Count: 5

Problem:

Optional arguments still show up in the arguments scope, but as undefined values (they're null).

This is VERY confusing because structKeyList/Array() will return the key, and cfloop will loop over the key, but accessing it causes an error.

Lots and lots of code has workaround for this (like Transfer) that requires looping over the entire structure deleting the keys, even com.adobe.System has manipulateArguments() to work around this internally.
Method:

<!--- comp.cfc --->
<cfcomponent>

	<cffunction name="foo" returnType="struct">
	
		<cfargument name="arg1" required="true">
		<cfargument name="arg2" required="false" default="arg2">
		<cfargument name="arg3" required="false">
		<cfargument name="arg4">
		
		<cfreturn arguments>
	
	</cffunction>

</cfcomponent>

<!--- bug76181.cfm --->
<cfset args = new comp().foo(10)>
<cfdump var="#args#">

Result:

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

Watson Bug ID:	3038002

External Customer Info:
External Company:  
External Customer Name: Elliott Sprehn
External Customer Email: 202D59C844579997992016B7
External Test Config: 03/25/2009

Attachments:

Comments:

This bug has been voted..
Vote by External U.
23838 | November 10, 2011 07:18:06 PM GMT
This drives me crazy too. I've seen many beginners very confused by this behavior as well.
Vote by External U.
23839 | November 10, 2011 07:18:07 PM GMT
This bug has been voted..
Vote by External U.
23840 | November 10, 2011 07:18:08 PM GMT
Totally agree. This drives me crazy every time I have to loop over an argument list. Checking for individual args is not too bad because you'd use structKeyExists() anyway but if you have to loop over the args, this is a crazy workaround to have to employ. As Elliott says, even Adobe's own CFC wrappers have to have this workaround!
Vote by External U.
23841 | November 10, 2011 07:18:09 PM GMT
This bug has been voted..
Vote by External U.
23842 | November 10, 2011 07:18:10 PM GMT