structEach() on arguments scope sends incorrect values to callback function

Description

If you loop over the arguments scope with structEach() it does not pass the correct values to the callback function. Normally the params are KEY, VALUE, STRUCT, but on the arguments scope it appears to be passing the value as key and the array index as value.

Here is code that demonstrates the issue:

1 2 3 4 5 6 7 8 9 10 11 12 13 <cfscript> function brokenStructEach( first, second, third ) { writeDump( var= arguments, label= 'arguments scope' ); structEach( arguments, function( key, value, struct ) { writeDump( var= arguments.key ?: 'key null', label= 'arguments key' ); writeDump( var= arguments.value ?: 'value null', label= 'arguments value' ); }); } writeDump( brokenStructEach( "Jordan", { "name"= "Jordan" } ) ); </cfscript>

The code is also in a trycf gist:
https://trycf.com/gist/e62da48609338c35538ec1b8fc271225/lucee5?theme=monokai

I attached screenshots of the results, first is ACF 2018 which correctly outputs the key/value for the arguments scope, the second image is the output from Lucee 5.

Interestingly the same problem does not happen for the key/values passed from of structEvery() or structFilter()

Environment

None

Status

Assignee

Pothys - MitrahSoft

Reporter

Jordan Clark

Fix versions

Affects versions

5.3.2.77

Priority

New
Configure