tracker issue : CF-3844976

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

append member functions don't return a useful value

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Bradley Wood / Bradley Wood (Bradley Wood)

Created: 10/29/2014

Components: Language

Versions: 11.0

Failure Type: Non Functioning

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Platforms All

Vote Count: 4

Listed in the version 2016.0.0.297996 Issues Fixed doc
The following  code sample works as expected on Railo, but throws an error on Adobe ColdFusion ("The append method was not found")

<cfscript> 
  writeDump( structNew().append( { foo:'bar' } ).append( { bum:'baz' } ) );
  writeDump( arrayNew( 1 ).append( 'a' ).append( 'b' ) );
</cfscript>

The issue is that the member functions do not return the struct/array, but a boolean.  While compatible with the old structAppend() and arrayAppend() functions, this makes them virtually useless in any scenario where I'm trying to clean up extra cruft code and append some things together on the fly as a self-contained expression that can be passed directly into another function, etc.

0
<cfscript> 
  leftProps = { borderLeft = 'THIN', leftBorderColor = 'blue' };
  topProps = { borderTop = 'THIN', topBorderColor = 'blue' }; 
  newStyle( {}.append( topProps ).append( leftProps ) )
</cfscript> 

(See bug 3844972 as well)

Again, the code above works great on Railo 4.2 and is what pretty much any scripting dev would expect from another language.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3844976

External Customer Info:
External Company:  
External Customer Name: bradwood.com
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

There is another ticket for this already raised by Adam C that was closed without explanation, so I'm entering a new one.
Comment by External U.
10391 | October 29, 2014 04:27:08 PM GMT
This is a valid ask, and we will be accommodating the fix in a future release. However, I will be closing this bug as a duplicate since the other bug (CF-3844972) is being tracked, and is a similar fix.
Comment by Immanuel N.
10392 | October 31, 2014 08:19:35 AM GMT
@Immanuel, they are not the same bug. CF-3844972 is about member function not working on literals whereas this one is about append function (and possibly others) not returning a useful value. Re-opening this one.
Comment by Rupesh K.
10393 | October 31, 2014 09:18:02 AM GMT
Thanks for catching that Rupesh. Also, the "0" above my second code sample wasn't what I typed. Was my description edited on purpose or on accident?
Comment by External U.
10394 | October 31, 2014 11:04:00 AM GMT
+1......................................
Vote by External U.
10414 | October 31, 2014 02:49:07 PM GMT
I think this should be reclassified as an enhancement request rather than a bug. The current behaviour of the "member function" version of the function matches the procedural one, and that is correct. Railo's different behaviour here is a bug, IMO. HOWEVER. The issue here is that the implementation of the baseline struct and array functions have always been a bit limp: they should *always* have returned the struct/array in question. These functions should be altered accordingly, and also accordingly the member function versions should also be modified to be in step with them (which I think they would be as a matter of course anyhow). The behaviour of the member functions should *not* differ from that of the prodcedural ones though. That would be a poor design decision. -- Adam
Comment by External U.
10395 | October 31, 2014 02:53:05 PM GMT
I'm dead keen to know about the potential editing of Brad's ticket detail too, TBH. I've had the impression some of my tickets have been surreptitiously edited in the past, but could never "prove" it. This bug trackers needs a "view history" option. -- Adam
Comment by External U.
10396 | October 31, 2014 02:54:33 PM GMT
+1 for the totality of Adam's post on "1:23:05 PM GMT+00:00 Oct 31, 2014". The built-in functions _and_ their member function counterparts should be updated to return a useful value. Perhaps include this in CF12's language overhaul?
Vote by External U.
10415 | November 01, 2014 05:25:09 AM GMT
@Brad & @Adam We don't change the bug title or description. There might have been some extremely rare cases when the title or the description of bug is totally wrong or inappropriate and we would have corrected it but that would be extremely rare. I have checked the audit trail of this bug and I don't see any change made in this. It might have been a typo when you logged the bug.
Comment by Rupesh K.
10397 | November 04, 2014 05:54:03 AM GMT
Multiple consecutive appends should work perfectly now, as the return type is updated from boolean to the respective datatypes: hence these cases should work perfectly: <cfscript> writeDump( structNew().append( { foo:'bar' } ).append( { bum:'baz' } ) ); </cfscript> <cfscript> x = {}; x.append({foo:'bar'}); </cfscript> However, the following type of statement is not supported: <cfscript> x = {}.append({foo:'bar'}); </cfscript>
Comment by Nikhil S.
10398 | November 21, 2014 06:00:07 AM GMT
Hi Nikhil, What built-in functions were changed? Only StructNew() and ArrayNew()? Thanks!, -Aaron
Comment by External U.
10399 | November 26, 2014 05:32:22 AM GMT
Adobe, can you pls answer that question?
Comment by External U.
10400 | May 25, 2015 07:50:19 AM GMT
Oh, and which version was this fixed in? I'm running 11,0,05,293506 and this code: st = {}; writeDump(st.append({foo="bar"})); Results in "YES", when it should result in {foo="bar"} I'd say... no, it's not fixed.
Comment by External U.
10401 | May 25, 2015 07:54:37 AM GMT
And your own example code doesn't work either.
Comment by External U.
10402 | May 25, 2015 07:55:21 AM GMT
Looks like I missed the comments back on November. Nikhil, can clarify if {}.append({foo:'bar'}); doesn't work because it's not possible, or if you're waiting to implement that as part of bug # CF-3844972? That syntax is supported in Railo/Lucee and I'd like to see it in Adobe CF as well.
Comment by External U.
10403 | May 25, 2015 11:09:01 PM GMT
This fix is supposed go out in a later build (CF12 Alpha). Hence the examples won't work as of now.
Comment by Nikhil S.
10404 | May 27, 2015 03:35:28 AM GMT
I think you need to add a field "targeted for release", to avoid confusion like this.
Comment by External U.
10405 | May 27, 2015 03:43:02 AM GMT
(sorry, where that field has the release version it's tentatively targeted for)
Comment by External U.
10406 | May 27, 2015 03:43:28 AM GMT
casting my vote, so +1 from me
Vote by External U.
10416 | July 09, 2015 02:10:00 PM GMT
Related: https://bugbase.adobe.com/index.cfm?event=bug&id=CF-4018933
Comment by External U.
10407 | July 09, 2015 02:20:11 PM GMT
Related: https://bugbase.adobe.com/index.cfm?event=bug&id=CF-4018933
Vote by External U.
10417 | July 09, 2015 02:20:20 PM GMT
Adobe, Could you please answer my question? (from 3:02:22 AM GMT+00:00 Nov 26, 2014) ----------- What built-in functions were changed? Only StructNew() and ArrayNew()? ----------- Thanks!, -Aaron
Comment by External U.
10408 | September 21, 2015 09:29:34 AM GMT
append member functions for Array and Struct to return array/struct respectively. These member-functions have changed. StructAppend() & ArrayAppend() will continue to retuen boolean values. Thanks, Suchika.
Comment by Suchika S.
10409 | September 21, 2015 10:55:24 AM GMT
Hi Suchika, Very cool and thanks very much for clarifying! -Aaron
Comment by External U.
10410 | September 21, 2015 11:10:11 AM GMT
Excellent news, cheers Suchika. You have still to populate the "fixed in build" field for this ticket though.
Comment by External U.
10411 | September 22, 2015 01:33:58 AM GMT
So this was fixed for append member functions, but not other member functions. And the headless ones remained unchanged. We need to file separate tickets to fix each member function? As well as the headless ones? Again, +1 to Adam's comment below: -------------------------------------------- The issue here is that the implementation of the baseline struct and array functions have always been a bit limp: they should *always* have returned the struct/array in question. These functions should be altered accordingly, and also accordingly the member function versions should also be modified to be in step with them (which I think they would be as a matter of course anyhow). The behaviour of the member functions should *not* differ from that of the prodcedural ones though. That would be a poor design decision. -------------------------------------------- Aether should fix these language issues, since Raijin didn't do as promised. Thanks!, -Aaron
Comment by External U.
10412 | May 12, 2016 05:58:30 PM GMT
FWIW, filed CF-4152447 to likewise update the .sort() member functions. Thanks!, -Aaron
Comment by External U.
10413 | May 12, 2016 09:25:18 PM GMT