Cannot default first argument in reduce()'s callback with full null support

Description

See http://blog.adamcameron.me/2017/04/cfml-lucee-13-v-4-14-v-6-coldfusion-we.html

See this test case:

describe("reduce tests", function(){ var numbers = duplicate(baseNumbers); it ("accepts a default for the first argument", function(){ var ids = numbers.reduce(function(sum=[], row){ return sum.append(row.id); }); expect(ids).toBe([1,2,3,4]); }); it ("accepts an initial value", function(){ var ids = numbers.reduce(function(sum, row){ return sum.append(row.id); }, []); expect(ids).toBe([1,2,3,4]); }); });

The first test fails on Lucee because it does not respect the default value for that sum argument.

Environment

None

Activity

Show:

Adam Cameron 6 July 2021 at 18:55

This is a duplicate of https://luceeserver.atlassian.net/browse/LDEV-53 and can be closed.

Pothys - MitrahSoft 14 December 2020 at 10:28
Edited

I've checked this ticket with lucee latest version 5.3.8.119-SNAPSHOT issue not yet fix.
Without enableNullSupport both lucee and ACF work fine. With enableNullSupport and default value on the first argument in the callback function, lucee throws an error. Seems ACF works fine. So I added a testcase for this ticket.

Pull Request: https://github.com/lucee/Lucee/pull/1119

Pothys - MitrahSoft 5 May 2017 at 15:04

I've added test case for this ticket & confirmed that issue happened on latest version of lucee. In windows, it doesn't set default value for argument(sum) in member function. But In linux, it defined default value for argument(sum). It's working fine on linux.

PullRequest: https://github.com/lucee/Lucee/pull/228

Details

Assignee

Reporter

Priority

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

Affects versions

Created 2 May 2017 at 08:43
Updated 14 July 2021 at 14:35

Flag notifications