Conditional statement bug

    <cfset i = 8/>
    <cfdump label="before" var="#i#"/>
    <cfif i = 20>
      <!--- do somthing --->
    <cfdump label="now" var="#i#"/> <!--- i is now 20 ---> 

Conditional statement should not be converted to an assignment statement.
This is a bug, AC flagged this error in runtime

This affects all lucee versions

1 Like

In CF:
= assign
== compare (or “EQ”)

than you should use “==”

Am fully aware of this, what am saying is that the compiler should throw an error to mitigate this

This is not the case in Adobe Coldfusion, its reported as syntax error.
Assignment in conditional statement should not be possible

1 Like

Yeah, it should throw an invalid construction error. ACF throws an error, so this seems to be an incompatibility issue in Lucee. Could you please file a bug in Jira?

thanks, i got it now.

It’s not really a conditional statement bug; it’s that in Lucee an assignment is an expression; whereas in CFML it should be a statement.


writeOutput((i=1).getClass().getName()) // lucee: java.lang.Double; CF: syntax error

But agree it’s a bug.