tracker issue : CF-4204918

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

CFSCRIPT: UDF - Use of "Default" in first argument results in error.

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/Duplicate

Reporter/Name(from Bugbase): Bryon N. / ()

Created: 08/03/2019

Components: Language, CFSCRIPT

Versions: 2018

Failure Type: Incorrect w/Workaround

Found In Build/Fixed In Build: 2018.0.04.314546 /

Priority/Frequency: Normal / All users will encounter

Locale/System: English / Win 2016

Vote Count: 0

Problem Description:
In CFSCRIPT in a User Defined Function If the first argument contains "Default" then a run time error occurs.

This issue only exists on the first argument of each function. The second argument works fine with a default value.

Error returned: 
"The DEFAULT argument passed to the init function is not of type [argument name]."

Steps to Reproduce:
1) Create a function in cfscript that contains a default value. 
2) Call the function.

This always returns the error. It does not matter if it's in a CFC or CFM page. It occurs no matter the type defined.

Example:
<cfscript>
    function test(string myVariable default="" hint="This should define a default value for the argument"){ return this;	}
</cfscript>
<cfset test()>
<cfset test("a")>

Actual Result:
Error:
"The DEFAULT argument passed to the init function is not of type myVariable."
or
"The DEFAULT argument passed to the init function is not of type [argument name]."

ColdFusion is interpreting the argument and as type instead of the variable name.
The error only occurs on the first argument.

Expected Result:
The a default value should be created for the argument. 
The error should NOT occur. 
ColdFusion should not think the argument name is a type.

Any Workarounds:
Remove all default values and use param to define a default value.

Attachments:

Comments:

Duplicate of ticket CF-4204917
Comment by Aaron N.
31097 | August 04, 2019 02:18:42 AM GMT