tracker issue : CF-4202736

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

[ANeff] Bug for: null support ignores conditionals

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

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

Created: 06/06/2018

Components: Language, Null Support

Versions: 2018

Failure Type: Data Corruption

Found In Build/Fixed In Build: 2018.0.01.308605 (PreRelease) / 2018,0,0,310306

Priority/Frequency: Normal / Most users will encounter

Locale/System: / Windows 10 64 bit

Vote Count: 0

Issue: null support ignores conditionals

Steps to Reproduce:

1) Enable NULL support
 2) Run this:

<cfscript>
 if(false)

{foo="bar"}

writeOutput(variables.keyExists("foo"))//returns YES (bad)
 writeOutput(isNull("variables.foo"))//returns YES (bad)
 writeOutput(isNull("foo"))//throws Variable FOO is undefined. (good)
 </cfscript>

Actual Result: YES YES UndefinedVariableException

Expected Result: NO NO UndefinedVariableException

3) Run this:

<cfscript>
 function f() {
 var someValue = "a"
 switch(someValue) {
 case "b":

{ var foo = "bar" break }

}
 return local.keyExists("foo")
 }
 writeDump(f())//returns YES (bad)
 </cfscript>

Actual Result: YES

Expected Result: NO

4) Run this:

<cfscript>
 myArray=[]
 for(element in myArray)

{ foo = "bar" }

writeDump(variables.keyExists("foo"))//returns YES (bad)
 </cfscript>

Actual Result: YES

Expected Result: NO

Wow!!

Do I really need to test every scenario? Adobe, if you think it's okay for variables to exist before their creation: no, it's not okay!

I guarantee this is going to break a TON of code. Checking for existence of variables, and making decisions upon that, is common.

Attachments:

Comments:

I wish I could edit the description. I had a typo. The 2nd snippet (w/ the switch/case) should've been: <cfscript> function f() { var someValue = "a" switch(someValue) { case "b": { var foo = "bar" break } } return local.keyExists("foo") } writeDump(f())//returns YES (bad) </cfscript>
Comment by Aaron N.
28963 | June 06, 2018 06:01:11 AM GMT
Aaron - I've made the necessary edit.
Comment by Vamseekrishna N.
28964 | June 06, 2018 06:36:41 AM GMT