tracker issue : CF-4202592

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

Chained function calls silently do the wrong thing

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Sean Corfield / ()

Created: 05/23/2018

Components: Language, Closures

Versions: 2018

Failure Type: Incorrectly functioning

Found In Build/Fixed In Build: Aether Public Beta / CF2018U5

Priority/Frequency: Normal / Some users will encounter

Locale/System: Arabic / Platforms All

Vote Count: 3

Problem Description:

If a function returns a closure, and it is immediately called, that call silently doesn't happen.

Steps to Reproduce:
{code:java}
<cfscript>
function foo( n ) {
    return function( m ) { return n + m; }
}

a = foo( 3 )( 4 );
writedump( a );
</cfscript>
{code}


Actual Result:

Prints out a closure object.

Expected Result:

Should print 7.

Any Workarounds:

Using an intermediate result variable:
a = foo( 3 );
a = a( 4 );

Attachments:

Comments:

Two notes: 1. This works as expected in Lucee. 2. This was a syntax error in CF2016 and earlier so, yay that you now accept the syntax, but silently doing the wrong thing is worse!
Comment by Sean C.
27926 | May 23, 2018 05:13:23 PM GMT
> silently doing the wrong thing is worse! yeah, not so good.
Comment by Adam C.
27931 | May 23, 2018 06:06:28 PM GMT
+1 - should definitely work as per Lucee
Vote by Aaron N.
27932 | May 23, 2018 08:31:56 PM GMT