tracker issue : CF-4203961

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

Coldfusion losing track of correct scope inside of recursive function

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/CannotReproduce

Reporter/Name(from Bugbase): William D. / ()

Created: 01/22/2019

Components: Language, Script CFC

Versions: 2016

Failure Type: Incorrectly functioning

Found In Build/Fixed In Build: 2016,0,03,300466 /

Priority/Frequency: Normal / Unknown

Locale/System: English / Windows 10 64 bit

Vote Count: 0

Problem Description:

In recursive functions, Coldfusion seems to default to the outer-most scope in some conditions resulting in infinite recursion. Additionally, specifically using the "arguments" scope for the structToFlatten seemed to make no difference.

Steps to Reproduce:

Code example: (Code simplified for sake of demonstration)

    public string function doThing(required struct thing) {
        var thingString = "";
        var keyArray = arrayNew(1);

        // thing correct here

        for (key in thing) {
            // structToFlatten correct here
        }

        var keyList = listSort(arrayToList(keyArray),"text");

        for (i = 1; i lte listLen(keyList); i++) {
            var key = listgetat(keyList, i);
            var obj = thing[key];

            // thing, key, obj is from outermost scope here

            if(isStruct(obj)) {
                // thing, key, obj is from outermost scope here
                thingString = doThing(obj);
            } 
        }

        return thingString;
    }


Actual Result:

Recurses infinitely as it is continuously working on the same object which consistently meets the requirements to recurse.

Expected Result:

Uses the variable passed to it in the arguments

Any Workarounds:

No

Attachments:

Comments:

Also tested on ColdFusion 2016 Update 7, same result.
Comment by William D.
30135 | January 22, 2019 09:21:57 PM GMT
Hi William, Can you send us a reproducible code ? I tried reproducing at our end but was not successful.  Regards, Suchika.
Comment by Suchika S.
30514 | March 15, 2019 09:38:42 AM GMT
Hi William , We have not received any response and we believe that this issue was resolved at your end. Hence , we are closing this bug. If you are still facing this issue , please email me at suchsing@adobe.com. Regards, Suchika
Comment by Suchika S.
33232 | March 03, 2020 08:06:53 AM GMT