Array.every incompatibility with ACF

Description

Might be hard to change since there is probably code that relies on current Lucee behavior.

Empty arrays are treated incompatibly between Lucee5 and ACF2021, when used as the receiver for `array.every`

<cfscript> a = []; x = a.every((v) => true); y = arrayEvery(a, (v) => true); // lucee – [false, false] // adobe – [true, true] writedump([booleanformat(x),booleanformat(y)]); </cfscript>

Maybe just a curiosity, but as precedent in other languages, JS also has this exact syntax as a member function, and the empty array produces true:

/* javascript */ [].every(v => true) // true

Environment

None

Activity

Show:

Adam Cameron 6 May 2022 at 14:40

This is relevant here: https://en.wikipedia.org/wiki/Vacuous_truth#In_computer_programming

I can also confirm that Kotlin (probably because of the underlying Java does, that said) and Ruby apply this approach.

Pothys - MitrahSoft 15 February 2022 at 13:34
Edited

I added a testcase to some list, array & struct Functions
Pull Request: https://github.com/lucee/Lucee/pull/1571

Pothys - MitrahSoft 14 February 2022 at 12:06

I added a testcase to this ticket

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

Pothys - MitrahSoft 11 February 2022 at 15:18

I've checked this ticket and confirmed the issue happened on the lucee latest version Lucee 5.3.9.80-SNAPSHOT. arrayEvery() with empty array returns false in lucee but ACF returns true. The regression starts from 5.2.2.51-SNAPSHOT.

https://github.com/lucee/Lucee/commit/b83f4b6579725a18136871fd831b0c21c40a2b4d

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

Sprint

Affects versions

Created 10 February 2022 at 18:40
Updated 6 March 2025 at 11:28

Flag notifications