Thursday, 17 January 2013

Shorthand struct notation is still buggy (follow-up & repro case)

G'day;
Brad Wood has demonstrated that he is a bit of a star, in that he has concocted a repro case for that bug I mentioned a coupla weeks back.  The repro case is buried down in the comments of that article, but here it is:


<cfscript>
function callMe(){
    if(1){    // always true, so always runs
        var var1 = dummy();    // so var1 is definitely set
        var var2 = dummy(test={bar=''});
    }

    // Try to use var1
    var var3 = var1;    // error on this line: "Variable VAR1 is undefined."
}

function dummy(){
    return "";
}

callMe();
</cfscript>

On ColdFusion versions 9.0.1, 9.0.2 and CF10.0.7, this errors where indicated.

It works fine on Railo 4.0.2.

Now that this can be repro'ed reliably, an issue on the bug tracker can be raised (and has been: 3482734).

Thanks again Brad.

Update:
Shorthand array notation has the same problem in this code too. This can be demonstrated by swapping the {bar=''} out for ['']


--
Adam