tracker issue : CF-3332168

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

Local scope is broken outside of CFCs

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/NotABug

Reporter/Name(from Bugbase): Scott Harvey / Scott Harvey (scott @ CLR)

Created: 09/17/2012

Components: Language

Versions: 10.0

Failure Type:

Found In Build/Fixed In Build: Final /

Priority/Frequency: Normal / All users will encounter

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

Vote Count: 0

Problem Description: I migrated from CF 8 to CF 10. In CF 8 I could update a variable in a structure called "Local" with the cfsavecontent function. This code is not in a cffunction and it  gives me unexpected results in CF 10.

I realize that CF 9 added a "local" scope within functions as mentioned here - http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSE99A664D-44E3-44d1-92A0-5FDF8D82B55C.html#WS5C402719-A146-427b-A16B-32304610F8F1 . I also realize that "Local" is a reserved word but according to the docs it is only reserved within function declaration http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec173d0-7ff8.html.

Steps to Reproduce:
<cfset Local = StructNew() />
<cfset Local.myString = "Why hello!!" />
<cfset Local.tempMyString = Local.myString />

<cfoutput>First time: Local.myString is #Local.myString#</cfoutput><br />

<cfsavecontent variable="Local.myString">
    Look at my shiny new string!!    
</cfsavecontent>

<cfoutput>Second time: Local.myString is #Local.myString#</cfoutput><br />

<cfset myLocal = StructNew() />
<cfset myLocal.myString = "Why hello!!" />
<cfset myLocal.tempMyString = myLocal.myString />

<cfoutput>First time: myLocal.myString is #myLocal.myString#</cfoutput><br />

<cfsavecontent variable="myLocal.myString">
    Look at my shiny new string!!    
</cfsavecontent>

<cfoutput>Second time: myLocal.myString is #myLocal.myString#</cfoutput>

Actual Result:
First time: Local.myString is Why hello!!
Second time: Local.myString is Why hello!!
First time: myLocal.myString is Why hello!!
Second time: myLocal.myString is Look at my shiny new string!! 

Expected Result:
First time: Local.myString is Why hello!!
Second time: Local.myString is Look at my shiny new string!!
First time: myLocal.myString is Why hello!!
Second time: myLocal.myString is Look at my shiny new string!! 

Any Workarounds:
The workaround is to change the name of the structure from "Local" to something else.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3332168

External Customer Info:
External Company:  
External Customer Name: scott @ CLR
External Customer Email:  
External Test Config: My Hardware and Environment details:



Server Product  ColdFusion  

Version  ColdFusion 10,282462  

Update Level  02  

Tomcat Version  7.0.23.0  

Edition  Enterprise    

Operating System  Windows Server 2008 R2    

OS Version  6.1    

Update Level  /C:/ColdFusion10/cfusion/lib/updates/chf10000002.jar    

Adobe Driver Version  4.1 (Build 0001)

Attachments:

Comments:

It works as expected on my development box Server Product ColdFusion Version ColdFusion 10,282462 Update Level 02 Tomcat Version 7.0.23.0 Edition Developer Serial Number Developer Operating System Windows 7 OS Version 6.1 Update Level /C:/ColdFusion10/cfusion/lib/updates/chf10000002.jar Adobe Driver Version 4.1 (Build 0001) Page outputs First time: Local.myString is Why hello!! Second time: Local.myString is Look at my shiny new string!! First time: myLocal.myString is Why hello!! Second time: myLocal.myString is Look at my shiny new string!!
Comment by External U.
18079 | September 17, 2012 02:39:17 PM GMT
Local is a keyword that was introduced in CF 9. Therefore the code using 'local' needs to be changed.
Comment by Rupesh K.
18080 | April 30, 2013 04:17:36 AM GMT