Title:
Returning literal struct within IF returns wrong value when ELSE branch exists
| View in TrackerStatus/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: