Skip to main content
Participating Frequently
Feb 19, 2016 10:14 PM UTC
Question

Am I the only one that thinks this is a bug in CF11?

I would love some feedback here from Adobe on whether or not this is a bug. If so, I will definitely report it but wanted to start here in the forums. Take a look at the cfscript code below:

array = [ {key1: "myKey"} ];

idx = 1;

tmp = array[idx];

writeDump( var=(array[1].key1 ?: ""), label="Prints 'myKey'" );

writeDump( var=(tmp.key1 ?: ""), label="Prints 'myKey'" );

writeDump( var=(array[idx].key1 ?: ""), label="Prints '[Empty String]'" );

The gist of what I am doing here is using the "elvis" operator to try and evaluate an object in realtime, and if the object cannot be evaluated, providing a default of an empty string. If you run this code, you will see that the first 2 methods of referencing array index 1 evaluate correctly and output my text but the 3rd does not. I realize that it would be better to check for the existence of a structure key explicitly but I am trying to use this approach for a massive refactor of some legacy code. It is stumping me as to why the 3rd method does not work so any input here would be greatly appreciated. As mentioned in the topic, I am using ColdFusion 11.

Thanks,

Micah

This topic is closed to new replies. Start a new post to keep the conversation going.

12 replies

Adobe Employee
Feb 23, 2016 10:28 AM UTC

This is an issue in CF11 & we have fixed this for the latest version of ColdFusion i.e ColdFusion2016.

Thanks,

Suchika.

Translate
Inspiring
Feb 23, 2016 10:54 AM UTC

I assume this will be fixed for (still supported) CF11?

Translate
EddieLotter
Inspiring
Feb 22, 2016 6:26 PM UTC

I cannot get the third item to work in CF11 update 7.

I tried variations in syntax, but they all fail.

Cheers

Eddie

Translate
jmicahAuthor
Participating Frequently
Feb 22, 2016 6:41 PM UTC

Thanks for testing and confirming the issue Eddie.

On Mon, Feb 22, 2016 at 12:27 PM, EddieLotter <forums_noreply@adobe.com>

Translate