Status/Resolution/Reason: To Fix//BugVerified
Reporter/Name(from Bugbase): George A. / ()
Created: 10/17/2019
Versions: 2018
Failure Type: Incorrect w/Workaround
Found In Build/Fixed In Build: 2018 Update 5 /
Priority/Frequency: Normal / Most users will encounter
Locale/System: English / Win 2012 Server x64
Vote Count: 0
Problem Description
RELATED TICKET: CF-4031746
REF PAGE: https://helpx.adobe.com/coldfusion/developing-applications/the-cfml-programming-language/using-coldfusion-variables/about-scopes.html
LOCAL and ARGUMENT scope evaluation or precedence is inconsistent when using unscoped variables. According to the reference page the order of evaluation is LOCAL and then ARGUMENTS. However, within a cfset ARGUMENTS is given priority on the left side of the equal symbol and LOCAL is on the right side.
Either the reference document is incorrect and needs to be updated to reflect this inconsistent evaluation or it’s a bug and should be corrected.
This is similar to ticket #CF-4031746 which was fixed in CF2016 Update 1, but that ticket did not address the incorrect scope being selected on the left side of an equal in cfset.
Steps to Reproduce
<cffunction name="scopetest" output="yes">
<cfargument name="path" type="string" required="yes">
<cfset LOCAL.path = 'E:'>
<cfset path = path & "\level1">
<cfset path = path & "\level2">
<br>ARGUMENT: #ARGUMENTS.path#
<br>LOCAL: #LOCAL.path#
<br>UNSCOPED: #path#
</cffunction>
<cfset scopetest(path='c:\windows\system32')>
Actual Results
LOCAL.path is set to “E:\”
ARGUMENTS.path is changed to “E:\level2”
As shown in the sample code, the path variable on the left side of the equals is evaluated as ARGUMENTS.path and the path variable on the right side of the equals is evaluated as LOCAL.path
Expected Results
LOCAL.path should be set to “E:\level1\level2”
ARGUMENTS.path should not be changed and stay “c:\windows\system32”
All unscoped usage of the path variable should reference LOCAL.path.
Workaround
Fully scope all LOCAL and ARGUMENTS scope variables.
Attachments:
Comments: