arrayMap/Each/Reduce skip null values

Description

Consider the following code:

// For Adobe compat nullValue=()=>{}; arr = ['test',nullValue()] writedump(arr) writedump(arr.map((x)=>'replaced'))

https://trycf.com/gist/50a3d3c527a467e6d748702f5d66e140/lucee5?theme=monokai

On Adobe, the map calls the closure twice and replaces both item in the original array. But on Lucee, the map closure is never called for null values, causing those values to be completely omitted from the final mapped array.

A “map” operation, by definition, must return the same number of elements as the original data structure. So it is explicitly invalid for Lucee to map an array with 2 indexes and return an array with only 1 index.

The same problem exists with arrayEach() and arrayReduce().

Activity

Show:

Brad Wood 4 July 2022 at 18:09

Oops. yes. I didn’t see those tickets, this one can be closed. I really hope this is fixed soon, it’s quite an oversight that seems like a rather simple fix.

Pothys - MitrahSoft 4 July 2022 at 05:49

Already there is have tickets for this issue https://luceeserver.atlassian.net/browse/LDEV-2523 & https://luceeserver.atlassian.net/browse/LDEV-4023. Shall I close this ticket as a duplicate?

Duplicate

Details

Assignee

Reporter

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

Priority

Created 1 July 2022 at 16:10
Updated 7 July 2022 at 05:40
Resolved 5 July 2022 at 05:45

Flag notifications