tracker issue : CF-4204008

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

`var` keyword is not honored within cfcatch tag

| View in Tracker

Status/Resolution/Reason: Open//

Reporter/Name(from Bugbase): Alexandre P. / ()

Created: 02/07/2019

Components: Language

Versions: 11.0

Failure Type: Data Corruption

Found In Build/Fixed In Build: Update 15 /

Priority/Frequency: Normal / Most users will encounter

Locale/System: ALL / Win 2008 Server R2 64 bit

Vote Count: 0

Problem Description: Declaring local variables using the `var` keyword doesn't work within the body of a cfcatch tag.

Steps to Reproduce:

<cfset test()>

<cffunction name="test">
	<cfset var immediateWithVar = true>
	<cfset local.immediateWithLocal = true>
	
	<cfdump var="#local#" label="local scope: immediate fn body">
	
	<cftry>
		<cfthrow message="error on purpose">
		<cfcatch type="any">
			<cfset var catchWithVar = true>
			<cfset local.catchWithLocal = true>
			
			<cfdump var="#local#" label="local scope: end of catch">
			<cfdump var="#variables#" label="variables scope: end of catch">
		</cfcatch>
	</cftry>
</cffunction>

Actual Result: The `catchWithVar` variable ends up in the `variables` scope rather than the `local` scope.

Expected Result: The `catchWithVar` variable should be declared within the `local` scope.

Any Workarounds: Use `local` instead of `var` to declare local function variables within the cfcatch's body.

Attachments:

Comments: