Status/Resolution/Reason: Closed/Fixed/Fixed
Reporter/Name(from Bugbase): Bradley W. / ()
Created: 09/24/2019
Components: Language, Closures
Versions: 2018
Failure Type: Data Corruption
Found In Build/Fixed In Build: Update 5 / CF2018U6
Priority/Frequency: Normal / Some users will encounter
Locale/System: / Platforms All
Vote Count: 1
Problem Description:
When a fat arrow function has curly braces around the body, ONLY an explicit return statement should return a value. The implicit return behavior only applies to a function body with no curlies.
This is following the standard JavaScript implementation of fat arrow functions:
https://stackoverflow.com/questions/35440265/curly-brackets-in-arrow-functions
Please fix this quickly as it will be a breaking change since fat arrows are already out now in update 5.
Steps to Reproduce:
{code:java}
<cfscript>
// Incorrectly returns 4. Should be undefined since no explicit return statement is used inside of curlies
func = x => { x+1 }
writeDump( func(3) )
</cfscript>
{code}
Actual Result:
4
Expected Result:
undefined
Attachments:
Comments: