Status/Resolution/Reason: Closed/Fixed/Fixed
Reporter/Name(from Bugbase): Thomas Harding / Thomas Harding ()
Created: 05/30/2017
Components: Language
Versions: 2016
Failure Type: Incorrectly functioning
Found In Build/Fixed In Build: Latest / 2020.0.0.314573
Priority/Frequency: Normal / All users will encounter
Locale/System: English / Windows 10 64 bit
Vote Count: 1
Problem Description: When fully quoting variable name assignment using dynamic keys, coldfusion errors when attempting to use a key that STARTS with a number. eg, "12345User" throws, but "User12345" does not.
Steps to Reproduce: The following code demonstrates the issue:
variables.key1 = "abc";
"variables.#variables.key1#" = "key1 works";
variables.key2 = "123";
variables[ variables.key2 ] = "key2 works!";
variables.key3 = "abc123";
"variables.#variables.key3#" = "key3 works!";
variables.key4 = "123";
"variables.#variables.key4#" = "key4 works!";
variables.key5 = "123abc";
"variables.#variables.key5#" = "key5 works!";
writeDump( var=variables );
Actual Result:
"Error: The string VARIABLES.variables.123 is not a valid ColdFusion variable name"
Expected Result:
All 5 keys should work using this notation.
Any Workarounds:
Use square bracket notation. However, this is not necessarily practical, as some javascript libraries that we use are sending the data in the format 'data[123][abc] = "this is some data"', where most other languages will automatically translate this to a struct, I have been using the quoted string notation as above to translate to struct data. Given that the depth of structs/keys could vary, it's far simpler to have it assigned this way, without needing to manually parse the keys and build up the resulting data struct in cf.
Attachments:
Comments: