tracker issue : CF-3039242

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

Bug 78715:The new, implicit "local" scope within a <cffunction> breaks backwards compatibility with previous versions of CF when creating a var'd variable called "local"

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Tim Blair / Tim Blair (Psionix)

Created: 07/13/2009

Components: Language, Functions

Versions: 9.0

Failure Type: Unspecified

Found In Build/Fixed In Build: 9,0,0,241018 / 246051

Priority/Frequency: Normal / Unknown

Locale/System: English / Mac 10 All

Vote Count: 3

Problem:

The new, implicit "local" scope within a <cffunction> breaks backwards compatibility with previous versions of CF when creating a var'd variable called "local".It's been mentioned [http://forta.com/blog/index.cfm/2009/6/21/The-New-ColdFusion-LOCAL-Scope#c0D8F50AC-3048-80A9-EF01363252C9BC50] that any statement that var-scopes a "local" variable (e.g. <cfset var local = {}>) is ignored.  Unfortunately, the compiler also ignores a definition such as <cfset var local = { foo = "bar" }> which is frequently used to populate pre-defined "local" variables, resulting in these variables not existing.Apparently this behaviour is documented (although I cannot find where), but still breaks backwards-compatibility.
Method:

<cffunction name="explicit_test"><cfset var local = { foo = "bar" }><cfreturn structkeyexists(local, "foo")></cffunction><cffunction name="implicit_test"><cfset local.foo = "bar"><cfreturn structkeyexists(local, "foo")></cffunction><cfoutput><h1>Testing backwards-compatibility for new <code>local</code> scope</h1><h3><code>foo</code> exists in:</h3><ul><li>explicit <code>local</code>: #yesnoformat(explicit_test())#</li><li>implicit <code>local</code>: #yesnoformat(implicit_test())#</li></ul><p>For backwards-compatibility to be maintained, both calls should return <code>Yes</code>.</p></cfoutput>
Result:

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

Watson Bug ID:	3039242

External Customer Info:
External Company:  
External Customer Name: Tim Blair
External Customer Email: 01CC32DD3FE0D08E9920157F
External Test Config: 07/13/2009

Attachments:

Comments:

This bug has been voted..
Vote by External U.
23492 | November 10, 2011 06:54:49 PM GMT
Agreed, this is a pretty major problem.
Vote by External U.
23493 | November 10, 2011 06:54:50 PM GMT
This will likely break some production code.
Vote by External U.
23494 | November 10, 2011 06:54:51 PM GMT