tracker issue : CF-4198389

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

Ternary operator doesn't short-circuit with implicit array/struct expressions

| View in Tracker

Status/Resolution/Reason: To Fix//Investigate

Reporter/Name(from Bugbase): Edward Keighley / Edward Keighley ()

Created: 03/06/2017

Components: Language, Expressions

Versions: 2016,11.0,10.0

Failure Type: Others

Found In Build/Fixed In Build: 11,0,10,300066 /

Priority/Frequency: Normal /

Locale/System: / Linux All

Vote Count: 2

Steps to Reproduce:

{code:java}
<cfscript>
a = 1; b = 1;
x = true ? [a++] : [b++];
writeDump(a);
writeDump(b);
writeDump(var=x, abort=true);
</cfscript>
{code}


Actual Result:
a==2 
b==2
x==[1]

Expected Result:
a==2
b==1
x==[1]

Any Workarounds:
a = 1; b = 1;
if(true) x=[a++]; else x=[b++];

Attachments:

Comments:

same failure on CF2016
1131 | March 06, 2017 11:58:54 AM GMT
This bug still exists in CF2018. Both branches are still evaluated. I don't understand how such a fundamental flaw in the language can have been left unaddressed for more than a year.
Comment by Edward Keighley
29938 | November 16, 2018 11:22:48 AM GMT