Strange behaviour of lambdas depending on curly brackets and return keyword

Description

This works

fn = (x) => arguments writeDump(fn("hello world"))

This also works

fn = (x) => {return arguments;} writeDump(fn("hello world"))

This throws an exception

fn = (x) => {arguments;} writeDump(fn("hello world"))

Example
https://trycf.com/gist/c1c1053c2f8e6487da1f5aad8fd91807/lucee5?theme=monokai

Environment

None

Activity

Show:

Brad Wood 23 September 2019 at 17:49

I believe this behavior is correct if we are matching the JavaScript spec on fat arrows. As soon as you use curly braces, an explicit return is required.

https://stackoverflow.com/questions/35440265/curly-brackets-in-arrow-functions

Brad Wood 14 August 2019 at 13:50

Is this ticket the same as https://luceeserver.atlassian.net/browse/LDEV-1621 ?

Pothys - MitrahSoft 12 September 2017 at 15:33

I've added test case for this ticket & confirmed that issue happened. Issue occurs while using curly braces in arguments & without return keyword.

Pull request: https://github.com/lucee/Lucee/pull/291

Details

Assignee

Reporter

Priority

Labels

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Created 7 September 2017 at 15:00
Updated 23 September 2019 at 17:49

Flag notifications