tracker issue : CF-4205268

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

Lambda/Fat Arrow expression requires block body syntax when returning a function

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Abram A. / ()

Created: 09/26/2019

Components: Language

Versions: 2018

Failure Type:

Found In Build/Fixed In Build: 2018,0,05,315699 - hf201800-4205242.jar / CF2018U6

Priority/Frequency: Normal /

Locale/System: / Linux

Vote Count: 1

When you return a function from a Lambda/Fat Arrow function, ColdFusion requires that you use the "block body" syntax.  This makes the code very cumbersome and goes against how other standard languages behave.

Here's an example (also at

say = (message)=>(to)=>()=>"#message# #to#";
sayHi = say("Hi");
sayHiToAdobe = sayHi("Adobe");
writeDump( sayHiToAdobe() );

Expected Results: 
Hi Adobe

Actual Results:
Invalid CFML construct found error.

The above code works in Lucee and is pretty much how you'd write it in JavaScript:
JavaScript Example:
say = (message)=>(to)=>()=>`${message} ${to}`
sayHi = say("Hi");
sayHiToAdobe = sayHi("Adobe");
()=>`${message} ${to}`
// "Hi Adobe"

This technique is common in functional style programming and makes composing, specializing functions, lazy evaluation and currying much more concise and easy to read and write.

You have to use the full function body expression syntax, which really defeats the purpose.
 say = (message)=>{ return (to)=>{return ()=>"#message# #to#"}};



Can't edit bug after submitting, but just FYI the JavaScript example had a copy/paste error. The line "()=>`${message} ${to}`" was not part of the code, but rather output from the console per the line above it.
Comment by Abram A.
31411 | September 26, 2019 07:51:27 PM GMT
Hi All, This issue is fixed now. Please reach out to ColdFusion support @ [|] to get the patch. -Nimit
Comment by Nimit S.
31457 | September 29, 2019 05:37:21 PM GMT