Title:
returntype of "function" is not honored but is not prohibited per the documentation
| View in TrackerStatus/Resolution/Reason: To Fix//
Reporter/Name(from Bugbase): Brian Ghidinelli / Brian Ghidinelli (Brian Ghidinelli)
Created: 05/05/2014
Components: Language, CF Component
Versions: 10.0
Failure Type:
Found In Build/Fixed In Build: Final /
Priority/Frequency: Normal / All users will encounter
Locale/System: English / Windows 7 64-bit
Vote Count: 1
Problem Description:
When I specify a <cffunction> tag with a returntype of "Function" (for a component named Function.cfc), CF10 does not properly mark the object as a type "Function" preventing it from being accepted by other components which require the type to be "Function".
Function is not listed in the documentation as being prohibited:
https://wikidocs.adobe.com/wiki/display/coldfusionen/cffunction
Surprisingly, this happens whether or not "Disable CFC Type Check" is enabled in the Administrator.
Steps to Reproduce:
Create Function.cfc:
<cfcomponent name="Function">
<cffunction name="init" output="false" access="public" returntype="Function">
<cfset this.foo = 1 />
<cfreturn this />
</cffunction>
<cffunction name="getFoo" output="false" access="public" returntype="numeric">
<cfreturn this.foo />
</cffunction>
</cfcomponent>
Create test.cfm:
<cffunction name="takeFunction" output="false" access="public" returntype="any">
<cfargument name="func" type="Function" required="true" />
<cfreturn arguments.func.getFoo() />
</cffunction>
<cfset o = createObject("component", "Function").init() />
<cfoutput>#takeFunction(o)#</cfoutput>
Actual Result:
Error Occurred While Processing Request
The value returned from the init function is not of type Function.
The error occurred in C:/Users/brian/Documents/web/trunk-main/test.cfm: line 8
6 : </cffunction>
7 :
8 : <cfset o = createObject("component", "Function").init() />
9 :
10 : <cfoutput>#takeFunction(o)#</cfoutput>
Stack Trace
at cftest2ecfm710216492._factor4(C:/Users/brian/Documents/web/trunk-main/test.cfm:8) at cftest2ecfm710216492.runPage(C:/Users/brian/Documents/web/trunk-main/test.cfm:1)
coldfusion.runtime.UDFMethod$InvalidReturnTypeException: The value returned from the init function is not of type Function.
at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:429)
at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368)
at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55)
at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:655)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:444)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:414)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2432)
at cftest2ecfm710216492._factor4(C:\Users\brian\Documents\web\trunk-main\test.cfm:8)
at cftest2ecfm710216492.runPage(C:\Users\brian\Documents\web\trunk-main\test.cfm:1)
...
Expected Result:
The number "1".
Any Workarounds:
* Rename CFC types to not be "Function"
* Update the CF10 documentation
However, it's worth noting that several libraries such as Transfer ORM have a "Function" component and depend on this to work. Transfer works for me in production however it fails to run its own unit tests because of this issue.
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3755175
External Customer Info:
External Company:
External Customer Name: brianatvfive
External Customer Email:
External Test Config: Windows 7, CF 10 Developer
Attachments:
Comments: