Status/Resolution/Reason: To Fix//BugVerified
Reporter/Name(from Bugbase): Alexandre P. / ()
Created: 02/05/2020
Components: Language, Functions
Versions: 2018
Failure Type: Incorrectly functioning
Found In Build/Fixed In Build: 2018,0,05,315699 /
Priority/Frequency: Normal / Some users will encounter
Locale/System: / Win 2016
Vote Count: 0
Problem Description: A component 'C' function 'F' with returntype="C[]" incorrectly returns 'null' when:
- The component's CFC file has just been saved
- 'F' function is called for the first time
- 'C' contains initialization code in the <cfcomponent> tag's body
Steps to Reproduce:
1. Create a Test.cfc file with that code:
<cfcomponent>
<cfset variables.CONSTANT = 1>
<cffunction name="emptyArray" access="public" returntype="Test[]">
<cfreturn []>
</cffunction>
</cfcomponent>
2. Create an index.cfm file with that code:
<cfset arr = createObject('Test').emptyArray()>
<cfdump var="#arr#">
3. Run index.cfm. If it doesn't cause an exception, try making changes to Test.cfc and run index.cfm again.
Actual Result: 'null' is returned in the specific scenario described above
Expected Result: An empty array is always returned
Any Workarounds: Haven't found any sane workarounds, but duplicating the function call ensures the proper value will be returned. Ex:
<cfset arr = test.emptyArray()>
<cfset arr = test.emptyArray()>
Attachments:
Comments: