Status/Resolution/Reason: Closed/Won't Fix/NotThisProduct
Reporter/Name(from Bugbase): bobo beebop / bobo beebop ()
Created: 05/12/2017
Components: Language, Functions
Versions: 10.0
Failure Type: Others
Found In Build/Fixed In Build: ColdFusion 10 update 18. /
Priority/Frequency: Normal /
Locale/System: / Win8 Server 64-bit
Vote Count: 0
Problem Description: ColdFusion 10 does not property catch errors when returning an anonymous struct.
Steps to Reproduce: The following code reproduces the error (also available in this gist https://www.trycf.com/gist/cae87ea85a24d2f51467c2153c3d410b/acf?theme=monokai). Line 4 raises an exception, but the exception is not caught.
<cffunction name="testCatch" returntype="struct">
<cftry>
<cfset foo = {}>
<cfreturn {"baz" = foo.doesNotExist}>
<cfcatch type="any">
<cfoutput>Caught the error. Proceeding.</cfoutput>
<cfreturn {}>
</cfcatch>
</cftry>
</cffunction>
<cfset testCatch()>
Actual Result: An error is thrown with the following message: `Element DOESNOTEXIST is undefined in FOO. on line 4`
Expected Result: Output: Caught the error. Proceeding.
Any Workarounds: Using an intermediate variable for the return works around the issue (https://www.trycf.com/gist/07dc1ca6bc01a9118a47214c17db8c4c/acf2016?theme=monokai). Note that lines 4 and 5 differ from the first gist.
<cffunction name="testCatch" returntype="struct">
<cftry>
<cfset foo = {}>
<cfset ret = {"baz" = foo.doesNotExist}>
<cfreturn ret>
<cfcatch type="any">
<cfoutput>Caught the error. Proceeding.</cfoutput>
<cfreturn {}>
</cfcatch>
</cftry>
</cffunction>
<cfset testCatch()>
Attachments:
Comments: