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

1

6

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?

Pithy answered 14/8, 2014 at 9:35 Comment(0)
V
5

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.

Vagabond answered 14/8, 2014 at 9:52 Comment(1)
And the Adobe engineer has agreed with my analysis of the situation, and the ticket is now reopened and marked "to fix" :-)Vagabond

© 2022 - 2024 — McMap. All rights reserved.