Status/Resolution/Reason: Closed/Fixed/Fixed
Reporter/Name(from Bugbase): Jake Churchill / Jake Churchill ()
Created: 04/19/2017
Components: Language, Functions
Versions: 2016,2018
Failure Type: Incorrectly functioning
Found In Build/Fixed In Build: 2016.0.03.301771 / 2018.0.02.312567
Priority/Frequency: Major / All users will encounter
Locale/System: ALL / Windows 10 64 bit
Vote Count: 8
Problem Description:
When passing a function closure to another function, if the argument type is string, the function is allowed to come through. I believe this to be incorrect
Steps to Reproduce:
See attached CFML file
Actual Result:
Passing a function closure to another function via an argument with type="string" allows the function to come through
Expected Result:
"Argument XYZ passed to function ABC is not of type string" error message by server
Any Workarounds:
None
Sample Code:
{code:java}<cffunction name="sayHello">
<cfargument name="person" type="string" />
<cfoutput>Hello, #ARGUMENTS.person#<br/></cfoutput>
</cffunction>
<cffunction name="testString">
<cfargument name="arg1" type="string" />
<cfdump var="#arguments#" label="arguments" expand="true" />
<cfif NOT isSimpleValue(arguments.arg1)>
<cfoutput>#Arguments.arg1("World")#<br/></cfoutput>
</cfif>
</cffunction>
<cffunction name="testFunction">
<cfargument name="arg1" type="function" />
<cfdump var="#arguments#" label="arguments" expand="true" />
<cfif NOT isSimpleValue(arguments.arg1)>
<cfoutput>#Arguments.arg1("World")#<br/></cfoutput>
</cfif>
</cffunction>
<cfoutput>
<strong>TESTS WITH FUNCTION</strong><br/>
I would expect this to fail based on argument type
<pre>testString(sayHello)</pre>result=
<cftry>
<cfset testString(sayHello) />
<cfcatch>
Error:#cfcatch.message#<br/>
</cfcatch>
</cftry>
<hr width=20% align=left>I would expect this to succeed
<pre>testFunction(sayHello)</pre>result=
<cftry>
<cfset testFunction(sayHello) />
<cfcatch>
Error:#cfcatch.message#<br/>
</cfcatch>
</cftry>
<hr><strong>TESTS WITH STRING</strong><br/>
I would expect this to succeed
<pre>testString('some string')</pre>result=
<cftry>
<cfset testString('some string') />
<cfcatch>
Error:#cfcatch.message#<br/>
</cfcatch>
</cftry>
<hr width=20% align=left>I would expect this to fail based on argument type
<pre>testFunction('some string')</pre>result=
<cftry>
<cfset testFunction('some string') />
<cfcatch>
Error:#cfcatch.message#<br/>
</cfcatch>
</cftry>
<hr><strong>TESTS WITH NUMBER</strong><br/>
I would expect this to succeed
<pre>testString(123)</pre>result=
<cftry>
<cfset testString(123) />
<cfcatch>
Error:#cfcatch.message#<br/>
</cfcatch>
</cftry>
<hr width=20% align=left>I would expect this to fail based on argument type
<pre>testFunction(123)</pre>result=
<cftry>
<cfset testFunction(123) />
<cfcatch>
Error:#cfcatch.message#<br/>
</cfcatch>
</cftry>
<hr><strong>TESTS WITH QUERY</strong><br/>
I would expect this to fail based on argument type
<pre>testString(QueryNew('id'))</pre>result=
<cftry>
<cfset testString(QueryNew('id')) />
<cfcatch>
Error:#cfcatch.message#<br/>
</cfcatch>
</cftry>
<hr width=20% align=left>I would expect this to fail based on argument type
<pre>testString(QueryNew('id'))</pre>result=
<cftry>
<cfset testFunction(QueryNew('id')) />
<cfcatch>
Error:#cfcatch.message#<br/>
</cfcatch>
</cftry>
<hr><strong>TESTS WITH STRUCT</strong><br/>
I would expect this to fail based on argument type
<pre>testString({})</pre>result=
<cftry>
<cfset testString({}) />
<cfcatch>
Error:#cfcatch.message#<br/>
</cfcatch>
</cftry>
<hr width=20% align=left>I would expect this to fail based on argument type
<pre>testString({})</pre>result=
<cftry>
<cfset testFunction({}) />
<cfcatch>
Error:#cfcatch.message#<br/>
</cfcatch>
</cftry>
<hr/><strong>TESTS WITH ARRAY</strong><br/>
I would expect this to fail based on argument type
<pre>testString([])</pre>result=
<cftry>
<cfset testString([]) />
<cfcatch>
Error:#cfcatch.message#<br/>
</cfcatch>
</cftry>
<hr width=20% align=left>I would expect this to fail based on argument type
<pre>testFunction([])</pre>result=
<cftry>
<cfset testFunction([]) />
<cfcatch>
Error:#cfcatch.message#<br/>
</cfcatch>
</cftry>
</cfoutput>
{code}
Attachments:
- April 19, 2017 00:00:00: closure.cfm
Comments: