tracker issue : CF-4207622

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

ArrayFilter only works when used in CFScript.

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/AsDesigned

Reporter/Name(from Bugbase): James M. / ()

Created: 03/20/2020

Components: Language, Array Functions

Versions: 2016

Failure Type: Non Functioning

Found In Build/Fixed In Build: 2016,0,14,318307 /

Priority/Frequency: Normal / Unknown

Locale/System: English / Win 2012 Server x64

Vote Count: 0

Problem Description:  CFML should function in both CFTag and CFscript mode.

Steps to Reproduce:
Try this using code on TryCF.com (I'd recommend using CFFiddle.org, but CF2016 is already being treated as EOL there.)

<cfset myArray = ["a1", "a2", "a3", "b4", "b5"]>
<cfset myFilter = arrayFilter(myArray, function(item) {
    return item.find("a");
})>
<cfdump var="#myFilter#">

It works with ColdFusion 2018 (and all versions of Railo & Lucee), but not CF2016.

Actual Result:

invalid CFMLConstruct error

Expected Result:

The filtered array (without any error).

Any Workarounds:

Modify your CFML and use cfscript tags when using the function.

Attachments:

Comments:

Hi James , Closure in Tags was a feature which was introduced in ColdFusion 2018 , hence all other versions prior to 2018 do not support the syntax as mentioned in the code sample. Thus , closing the bug. Regards, Suchika
Comment by Suchika S.
33318 | March 26, 2020 05:41:22 AM GMT
https://tracker.adobe.com/#/view/CF-4207622 ??? The official code sample for arrayFilter makes no mention that it doesn't support tag syntax. https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-a-b/arrayfilter.html Here's the sample as it currently exists (in case it's edited). I don't see any specific mention that tag-based syntax isn't supported.: <cfscript> superheroes=[ {"name":"Iron Man","member":"Avengers"}, {"name":"Wonder Woman","member":"Justice League"}, {"name":"Hulk","member":"Avengers"}, {"name":"Thor","member":"Avengers"}, {"name":"Aquaman","member":"Justice League"} ]; avengers=ArrayFilter(superheroes,function(item){ return item.member=="Avengers"; }); writeDump(avengers); </cfscript> The bug is the absence of information available in the documentation. According to the official Adobe ColdFusion online documentation, this feature was added in CF10. There's no indication anywhere that the function won't work in CF10, CF11 or CF2016 if used as a tag. How are developers, especially introductory or novice developers, that are working with older CF servers supposed to know this if it's not in the documentation? (This is one of the primary reasons that I posted this as a CF2016 bug.) If something doesn't work using both tag and script syntaxes in any past version of ColdFusion that the feature was introduced in, the shortcoming(s) should be identified... especially since there's only one version of the official documentation currently available. How many other function introduced in CF10, 11 or 2016 don't work as tags in a pre-CF2018 environment? Please strongly consider updating the documentation to specifically denote anything that doesn't support both tag & cfscript syntax.
Comment by James M.
33319 | March 26, 2020 03:12:20 PM GMT