tracker issue : CF-3616590

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

== doesn't compile if in a string

| View in Tracker

Status/Resolution/Reason: Closed/Won't Fix/

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)

Created: 08/22/2013

Components: Language

Versions: 9.0.1

Failure Type: Non Functioning

Found In Build/Fixed In Build: 9.0.1 /

Priority/Frequency: Major / Few users will encounter

Locale/System: English / Win XP All

Vote Count: 1

<cfscript>writeOutput("#1 == 2#");</cfscript>

This gives a compile error:
coldfusion.compiler.ParseException: Invalid CFML construct found on line 1 at column 26.
	at coldfusion.compiler.cfml40.ExpressionBody(
	at coldfusion.compiler.cfml40.StringPrimary(
	at coldfusion.compiler.cfml40.Literal(
	at coldfusion.compiler.cfml40.PrimaryExpression(
	at coldfusion.compiler.cfml40.UnaryExpression(
	at coldfusion.compiler.cfml40.ExponentialExpression(
	at coldfusion.compiler.cfml40.MultiplyDivisionExpression( (etc)

On the other hand, this works fine:
<cfscript>writeOutput("#1 EQ 2#");</cfscript>

To be clear, this is no production code, it's just a repro case.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3616590

Deployment Phase:	Release Candidate

External Customer Info:
External Company:  
External Customer Name: Adam Cameron.
External Customer Email:  
External Test Config: My Hardware and Environment details:



If you want to print "1 == 2" along with the pound sign, then you should use escape character like "##1 == 2##".
Comment by Nimit S.
14677 | December 13, 2013 04:16:56 AM GMT
Can you please just: a) read the ticket; b) try the code. It's clear from your comment you have not done either of those. -- Adam
Comment by External U.
14678 | December 13, 2013 04:23:26 AM GMT
I have tried it on (8,0,1,195765 , 9,0,0,251028 , 9,0,2,282541 ,10,0,11,285437) these versions and found the same behavior(error).
Comment by Nimit S.
14679 | December 13, 2013 08:54:42 AM GMT
Yes. That's the whole point. It. Shouldn't. Error. What's proving so difficult to understand here? -- Adam
Comment by External U.
14680 | December 13, 2013 09:04:57 AM GMT
IE: If this works fine: <cfscript>writeOutput("#1 EQ 2#");</cfscript> Where "works" is "outputs FALSE, because 1 != 2, so the expression is false. Then THIS should also work fine: <cfscript>writeOutput("#1 == 2#");</cfscript> Because it's the same logic, just a different operator. Do you get it? :-| -- Adam
Comment by External U.
14681 | December 13, 2013 09:18:29 AM GMT
This seems like it should be a simple fix and should just "work".
Vote by External U.
14689 | December 13, 2013 09:35:21 AM GMT
ACF does not accept cfscript expressions inside #..# in tag-based code. It has two expression parsers: one for tag-based code expressions, and one for cfscript. Pretty sure <cfif 1 == 2> .. </cfif> will not work either, for exactly the same reason.
Comment by External U.
14682 | December 13, 2013 12:40:44 PM GMT
That's not tag-based code, Sean. -- Adam
Comment by External U.
14683 | December 13, 2013 01:10:21 PM GMT
Interpolated strings are (treated as) tag-based code. Like I said: two expression parsers - one created for tag-based code that is used for expressions in cfset, cfif, interpolated strings etc - and one created for cfscript-based code.
Comment by External U.
14684 | December 13, 2013 01:25:37 PM GMT
Why would strings - which cannot possibly have tags in them - use the tag-version of the parser? That's not me disagreeing, I completely believe you: it's just general derision. Its a CFML expression, and how it is parsed should be tag/script agnostic, given an expression can appear in one as much as it can the other. Still: no quirk they could possibly come up with would surprise me about ColdFusion. Obviously Railo (and OpenBD even) deal with this fine. -- Adam
Comment by External U.
14685 | December 13, 2013 01:40:57 PM GMT
Remember that everything was tag-based original and so string interpolation used the expression parser from the tag-based world, along with cfset and cfif etc so everything was consistent. cfscript is essentially a whole separate parser but clearly reuses the original string handling logic. Railo seems to have a single, unified expression parser since "#1 == 2#" works fine on Railo. So it's more an issue of historical evolution of ColdFusion rather than a specific choice. It's hard to say (without looking at the code) how much work it would be to swap out the expression parser inside "#..#". Remember that "#..#" is used all over tag-based code - and inside cfscript for tag-in-script constructs like lock/transaction/etc. Changing the parser would impact pretty much every part of the language so it would be a "major" change in terms of QA and the potential to break existing code is large (*potential*... hard to know what existing code might rely on working or not working here).
Comment by External U.
14686 | December 13, 2013 01:58:32 PM GMT
Did you read through his report? He's not asking how to print a string with #s... For the love of all that is ColdFusion, please read and understand what he's talking about!
Comment by External U.
14687 | December 13, 2013 03:02:02 PM GMT
I read through the notes in the wrong order, I now see the follow up from that 1st response. By bad.
Comment by External U.
14688 | December 13, 2013 03:04:11 PM GMT