Status/Resolution/Reason: To Fix//Investigate
Reporter/Name(from Bugbase): John Whish / John Whish (John Whish)
Created: 11/01/2016
Components: Language, Closures
Versions: 2016,2018
Failure Type: Non Functioning
Found In Build/Fixed In Build: CF2016_Update3 /
Priority/Frequency: Critical / All users will encounter
Locale/System: ALL / Mac OS 9.04
Vote Count: 15
Problem Description:
Seems to be a scoping issue when nesting arrayEach.
Steps to Reproduce:
[http://trycf.com/gist/4dacc80fad8cac47d889f5b112216498/acf2016?theme=monokai]
{code:java}<cfscript>
function doit() {
var a = ["a", "b", "c"];
var b = ["x", "y", "z"];
var counter = 0;
arrayEach(a, function(foo) {
counter = 0;
arrayEach(b, function(bar) {
counter++;
// in dump counter is always 0
writeDump({
counter: counter,
foo: foo,
bar: bar
});
});
});
}
doit();
</cfscript>
{code}
Actual Result:
Counter is always output as having a value of 0
Expected Result:
Counter should increment per inner iteration
Any Workarounds:
Don't use arrayEach - use for each loop instead
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 4197194
External Customer Info:
External Company:
External Customer Name: John Whish
External Customer Email:
External Test Config: My Hardware and Environment details:
Attachments:
Comments: