tracker issue : CF-4205352

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

Returning literal struct within IF returns wrong value when ELSE branch exists

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/Duplicate

Reporter/Name(from Bugbase): Bob G. / ()

Created: 10/01/2019

Components: Core Runtime

Versions: 2018

Failure Type: Incorrectly functioning

Found In Build/Fixed In Build: 2018.0.05.315699 /

Priority/Frequency: Normal / Most users will encounter

Locale/System: English / Other

Vote Count: 4

Problem Description:

Returning literal struct within IF returns wrong value when ELSE branch exists.

Steps to Reproduce:

<cfdump var="#test()#" />

<cffunction name="test">
	<cfset var value = 0 />

	<cfif true>
		<cfset value = 1 />

		<cfreturn {
			value = value
		} />
	<cfelse>

	</cfif>
</cffunction>

Actual Result:

[return].value is 0

If the ELSE branch is branch is commented the result is the expected result below.

Expected Result:

[return].value to be 1

Any Workarounds:

Assign the return result to an intermediate variable:

<cfset result = {
	value = value
} />

<cfreturn result />

Attachments:

Comments:

Hi All, This issue is a duplicate of another bug #CF-4205251. Hence, I am withdrawing it as duplicate. Please refer the main bug for more information. -Nimit
Comment by Nimit S.
31524 | October 02, 2019 05:27:01 PM GMT