Title:
Bug 74323:In CF9, a LOCAL-scope variable can overwrite an ARGUMENT-scope variable having the same name
| View in TrackerStatus/Resolution/Reason: Closed/Fixed/
Reporter/Name(from Bugbase): Aaron Neff / Aaron Neff (Aaron Neff)
Created: 12/16/2008
Components: Language
Versions: 9.0
Failure Type: Unspecified
Found In Build/Fixed In Build: 0000 / 220525
Priority/Frequency: Major / Unknown
Locale/System: English / Win All
Vote Count: 1
Problem:
In CF9, a LOCAL-scope variable can overwrite an ARGUMENT-scope variable having the same name. This behavior differs from CF8.
Forum thread here: https://prerelease.adobe.com/project/forum/thread.html?cap=87529BDA13744B3DB718E841890B9240&forid={A8760B70-42A5-45FC-8BA2-DFCF173A9580}&topid={3CC148C6-D952-403D-9EC9-741120B5D654}
Method:
In the following example, CF8 returns '1' while CF9 returns '0':
<cffunction name="myFunction" access="public" output="no">
<cfargument name="id" type="numeric" default="1" />
<cfscript>
var local={};
local.id = 0;
</cfscript>
<cfreturn ARGUMENTS.id />
</cffunction>
<cfdump var="#myFunction()#" />
Also, Sean made a good observation - please see the 1st reply in this thread: https://prerelease.adobe.com/project/forum/thread.html?cap=87529BDA13744B3DB718E841890B9240&forid={A8760B70-42A5-45FC-8BA2-DFCF173A9580}&topid={3CC148C6-D952-403D-9EC9-741120B5D654}
It mentions how the following is now legal in CF9: (the 'Cannot declare local variable id twice.' error is not thrown)
<cffunction name="myFunction" access="public" output="no">
<cfargument name="id" type="numeric" default="1" />
<cfscript>
var id = 0;
</cfscript>
<cfreturn ARGUMENTS.id />
</cffunction>
<cfdump var="#myFunction()#" />
I also agree that this would break some code.
I'm rating the severity as '3/High' (at minimum) b/c I feel that if a new feature can break code in this manner, then it should not be rated as 'Easy Workaround'.
Result:
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3037072
External Customer Info:
External Company:
External Customer Name: Aaron Neff
External Customer Email: 3D1D17B03C844EBF992001AC
External Test Config: 12/16/2008
Attachments:
Comments: