tracker issue : CF-3117509

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

Clsoures do not work inside cfset.

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/AsDesigned

Reporter/Name(from Bugbase): Peter Boughton / Peter Boughton (Peter Boughton)

Created: 02/17/2012

Components: Language

Versions: 10.0

Failure Type: Non Functioning

Found In Build/Fixed In Build: Public Beta /

Priority/Frequency: Critical / All users will encounter

Locale/System: English / Platforms All

Vote Count: 1

Problem Description:
When attempting to define a function inline inside a cfset, it does not work.

Steps to Reproduce:

<cffunction name="doStuff">
	<cfargument name="SomeData" />
	<cfargument name="SomeFunction" />

	<cfreturn arguments />
</cffunction>

<cffunction name="NormalFunc">
	<cfreturn Arguments[1] + Arguments[2] />
</cffunction>

<cfscript>
// these three work:
X = doStuff( 'abc' , normalfunc );
X = doStuff( 'abc' , function(){return Arguments[1] + Arguments[2];} );
X = doStuff( SomeData='abc' , SomeFunction=normalfunc );
</cfscript>

<!--- passing in a function as a variable works, but using a closure does not work --->
<cfset X = doStuff( 'abc' , normalfunc ) />
<cfset X = doStuff( 'abc' , function(){return Arguments[1] + Arguments[2];} ) />

Actual Result:
Error: "Invalid CFML construct found" pointing at line/col of { character in closure definition

Expected Result:
A closure in cfset should work the same as in script.

Any Workarounds:

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

Watson Bug ID:	3117509

External Customer Info:
External Company:  
External Customer Name: boughtonp
External Customer Email:

Attachments:

Comments:

This is 'As designed'. The literal function is used in cfscript only and hence you cannot assign a function() in cfset nor can you define the same in cfset. (Comment added from ex-user id:sagarg)
Comment by Adobe D.
20778 | February 19, 2012 11:52:30 PM GMT
Be that as it may that it's "by design", Sagar, I think the point here is that it's *crap design* and should be changed. There's *NO REASON* why this should only work in CFScript. This all works OK in Railo, for example. -- Adam
Comment by External U.
20779 | March 14, 2013 06:59:45 PM GMT
+1 needs to be reopened and dealt with. -- Adam
Vote by External U.
20780 | March 14, 2013 07:00:09 PM GMT