ColdFusion 9 Ternary Operator Fail

One of the things that I was really excited for in ColdFusion 9 was the support for the ternary operator. As Ben said:

To me, the ternary operator is what the IIF() method call always wanted to be.

Unfortuately I was testing some CFML code, written and working on Railo, on a ColdFusion 9 server and had this error pop up:

Unable to find an operator implementation for coldfusion.compiler.ASToperator

Turns out the the ternary operator works great… unless you are using it in a default value for an argument. Fail.

Here is an example, that should run fine if the ternary operator was doing what it is supposed to:

<cffunction name="testing" access="public" returntype="void" output="false">
	<cfargument name="test" type="string" default="#(1 EQ 1 ? 'Hi' : 'Bye')#" />

	<!--- Anything --->
</cffunction>

I have filed it as a bug if you would like to vote on the issue.

Add Your Comments

Required
Required
Tips

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <ol> <ul> <li> <strong>

Your email is never published nor shared.

Ready?