tracker issue : CF-3198706

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

Default local scope in variables declared within functions

| View in Tracker

Status/Resolution/Reason: To Track//NeedMoreInfo

Reporter/Name(from Bugbase): Nando Breiter / Nando Breiter (Nando Breiter)

Created: 05/25/2012

Components: Language

Versions: 10.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: Final /

Priority/Frequency: Major / Most users will encounter

Locale/System: English / Platforms All

Vote Count: 3

Problem Description: By default, variables defined inside a function or method are stored in the variables scope. This can cause threading problems or memory leaks if a developer forgets to local scope the variable using "var variableName". In practice, almost all variables declared in functions are meant to be local, and if they are not, they are explicitly declared using the variables scope for clarity. A helpful enhancement would be to provide a setting where a developer could specify that all variables declared in functions that are not explicitly scoped are placed in the local scope. This setting might be placed at the component, application or server level. To me, the most useful would seem to be at the application level.

Thanks for considering this enhancement request.


Steps to Reproduce:

Actual Result:

Expected Result:

Any Workarounds:

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

Watson Bug ID:	3198706

External Customer Info:
External Company:  
External Customer Name: Nando Breiter
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

leads to difficult to find bugs
Vote by External U.
19203 | May 30, 2012 04:27:45 AM GMT
Spent several hours trying to track down the fact that I hadn't var scoped a query name in a cfc.
Vote by External U.
19204 | May 31, 2012 08:43:34 PM GMT
This issue is well documented across many CF blogs. It is especially a problem when you define cfcs in a persistant scope such as sever/application where variables are defaulted globally across the application with downstream issues such as a user displaying the username as someone else.
Vote by External U.
19205 | February 17, 2014 11:29:17 AM GMT