Interesting Struct Error

Here is an interesting error…

<cfset session.y = structNew()>
<cfset session.y.z = “foo”>

You would expect to get an error saying zz did not exist in y, and you would if you were using another top level structure beside session. However, when you run this code, you get:

“Element Y is undefined in SESSION. “

Obviously that isn’t the case. So, if you see this error, be aware it may actually be talking about a lower level structure. As I said, I did NOT see this in a ‘simple’ structure, so I’m guessing something about Session’s special nature causes the incorrect error. I just did a test and the same thing happens with Application and Server.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA