tracker issue : CF-4204062

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

CFML Compiler Fails to Assign a Closure containing arguments to a Dynamic Key in a Structure

| View in Tracker

Status/Resolution/Reason: To Test//Fixed

Reporter/Name(from Bugbase): Robert Y. / ()

Created: 03/04/2019

Components: Functions

Versions: 2016,11.0

Failure Type: Others

Found In Build/Fixed In Build: 2016.0.10.314028 /

Priority/Frequency: Normal / All users will encounter

Locale/System: English / Windows 10 64 bit

Vote Count: 0

Problem Description:

    The CFML Compiler will fail if, in CFSCript, you are attempting to assign a Closure that contains arguments to a dynamic key in a structure. If the Closure does not have any arguments it will not cause this issue.


Steps to Reproduce:
<cfscript>
        function createDynamicKey( key ){
		return 'Dynamic_' & key;
	}

	var structure = {};
	var key = createDynamicKey( 'Key' );
	structure[ key ] = function( value ){
		return value;
	};

	writedump(var=structure, top=2); abort;
</cfscript>

Actual Result:

    An error occurs with the message: "Invalid CFML construct found on line..."
The error specifically points to this snippet of code as the cause: "structure[ key ] = function( value )"

Expected Result:
    A structure containing the key "Dynamic_Key" with the closure as it's value.

Any Workarounds:
    The problem seems to be directly caused by the absence of a string in the square brackets during the assignment. If you use string interpolation to insert the variable into a string then it will work properly: 

structure[ '#key#' ] = function( value ){
	return value;
};

Attachments:

Comments: