Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shouldn't dot and square bracket notation behave the same in CF?

With this code:

<cfset foo = {}>
<cfset exists1 = !isDefined("foo.foo")>
<cfset exists2 = isNull(foo.foo)>
<cfset exists3 = isNull(foo['foo'])>

Railo passes ok (all True) while CF throws an exception on the last line.

coldfusion.runtime.UndefinedElementException: Element foo is undefined in a CFML structure referenced as part of an expression.

I've always thought the dot notation and the square bracket notation in CFML should be functionally equivalent other than only square bracket can define case-sensitive keys.

A bug I reported here is recently marked "NotABug".

Can someone explain why?

like image 592
Henry Avatar asked Aug 14 '14 09:08

Henry


1 Answers

I've added a comment to the bug. Basically the reason Adobe closed it as "not a bug", is because their engineer who triaged it is a muppet. It's def a bug.

And it's because of the bug your code doesn't work.

like image 99
Adam Cameron Avatar answered Oct 17 '22 18:10

Adam Cameron