tracker issue : CF-3042593

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

Bug 84833:(Watson Migration Closure)[ANeff] Bug for: Clearing local scope odd behavior (ignore #84831)Please disregard #84831

| View in Tracker

Status/Resolution/Reason: Closed/Won't Fix/

Reporter/Name(from Bugbase): Aaron Neff / Aaron Neff ()

Created: 10/26/2010

Components: Language, CF Component

Versions: 9.0.1

Failure Type: Unspecified

Found In Build/Fixed In Build: 0000 /

Priority/Frequency: Normal / Unknown

Locale/System: English / Win All

Vote Count: 4

Problem:

[ANeff] Bug for: Clearing local scope odd behavior (ignore #84831)Please disregard #84831. The issue exists in both CF8 & CF9. After deleting a local variable (or even clearing the function local scope entirely), un-scoped assignment of same-named variable writes to local scope (instead of variables scope). This can be especially troublesome when using onRequest(), b/c an included page cannot use a same-named variable, even after calling structClear(local). Here are a couple of simplified examples:--------------1) CF9 Example--------------<cfscript>  function myFunction() {    var myVar="";    structDelete(local, "myVar", true);//ensure myVar does not exist in local scope    structClear(local);//clear local scope entirely    myVar="";//attempt to create variables.myVar    writeOutput(variables.myVar);//ERROR: Element MYVAR is undefined in VARIABLES  }  myFunction();</cfscript>--------------------2) CF8 & CF9 Example--------------------<cfscript>  function myFunction() {    var myVar="";    structDelete(getPageContext().getActiveFunctionLocalScope(), "myVar", true);//ensure myVar does not exist in local scope    structClear(getPageContext().getActiveFunctionLocalScope());//clear local scope entirely    myVar="";//attempt to create variables.myVar    writeOutput(variables.myVar);//ERROR: Element MYVAR is undefined in VARIABLES  }  myFunction();</cfscript>
Method:


Result:

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

Watson Bug ID:	3042593

External Customer Info:
External Company:  
External Customer Name: Aaron Neff
External Customer Email: 3D1D17B03C844EBF992001AC
External Test Config: 10/26/2010

Attachments:

Comments:

What do you mean it's "not a bug"?
Comment by External U.
21346 | November 28, 2014 03:17:24 AM GMT
This is definitely a bug. If you try to reference the local variable after deleting it from local scope, ColdFusion complains there's no such variable. If there's no such local variable, assigning to it should go to variables scope, exactly as if you hadn't declared the local variable in the first place.
Vote by External U.
21356 | November 28, 2014 03:22:59 PM GMT
Adobe, Please re-open. This is a bug (still exists in CF11 Update 3 (11,0,03,292245(PreRelease))). Repros (b/c Watson Migration mangled description): Repro #1: index.cfm -------------- <cfscript> function myFunction() { var myVar=""; structDelete(local, "myVar", true);//ensure myVar does not exist in local scope structClear(local);//clear local scope entirely writeDump(local); myVar="";//attempt to create variables.myVar writeOutput(variables.myVar);//ERROR: Element MYVAR is undefined in VARIABLES } myFunction(); </cfscript> Repro #2: Application.cfc: ---------------------- component { THIS.name = "ticket_CF-3042593"; myVar = "in constructor"; function onRequest() { var myVar = "in onRequest()"; structDelete(local, "myVar", true); structClear(local); include "myinclude.cfm"; } } myinclude.cfm --------------------- <cfscript> myVar = "in include"; writeDump(variables.myVar);//returns "in constructor" (bug b/c should return "in include") </cfscript> Repro #2 is a gotcha, if one's unaware and doesn't prefix w/ "variables." during assignment. Thanks!, -Aaron
Comment by External U.
21347 | November 28, 2014 09:13:09 PM GMT
IsABug
Comment by External U.
21348 | August 29, 2015 03:09:56 AM GMT
Adobe? Lift your game, pls.
Comment by External U.
21349 | August 29, 2015 03:29:44 AM GMT
This is as designed and we will not support cases when any un-scoped assignment after clearing local scope to get added to variables scope. (Comment added from ex-user id:sandeepp)
Comment by Adobe D.
21350 | September 25, 2015 04:18:52 AM GMT
Why is this the design though, Sandeep? And it's a bit presumptuous of you to simply say "it's as designed" and then close it. What if the consensus is the design was wrong? I'm not saying it is wrong, but this is not the way to conduct a discussion on an issue.
Comment by Adam C.
21351 | February 10, 2017 01:00:24 PM GMT
Seconding Adam's question: WHY is this by design? Deleting a variable out of a scope should not force future unscoped variables into that scope. How can doing so possibly make any sense?? BTW, I reported this in CF9, so you had plenty of time to fix it to avoid any "backward compat" issues. Thanks!, -Aaron
Comment by Aaron N.
21352 | February 10, 2017 09:27:03 PM GMT
BTW, Adobe, you need to document this sloppy behavior. And I'm eager to see what wording is used in the docs :) Thanks!, -Aaron
Comment by Aaron N.
21353 | February 10, 2017 09:33:00 PM GMT
Umm, Adobe, did you ever document this sloppy behavior? Or will you do the right thing: re-open/fix it. Thanks!, -Aaron
Comment by Aaron N.
21354 | July 19, 2017 05:25:41 PM GMT
Deleting a variable from a scope should not force future same-name variables into same scope.
Comment by Aaron N.
21355 | July 19, 2017 05:27:02 PM GMT
Is this thing on?
Comment by Aaron N.
29809 | October 20, 2018 02:06:44 AM GMT