I was doing some work with Dan Vega's Hyrule project yesterday and noticed some odd behavior where the validation routine would basically stop if I used an 'isMatch' validator. I checked the normal logs, etc and made sure there wasn't an errant abort or try/catch in the code and then I finally spotted the issue.
Basically it boils down to the fact that Dan had an outer and nested loop that were both var scoping the loop iterator of 'i'. This led to the unfortunate circumstance of prematurely ending the outer loop from completing. Consider the following code:
public void function foo(){
for(var i=1; i<=3; i++){
writeOutput('outer loop - i=' & i & '<br />');
for(var i=1; i<=2; i++){
writeOutput('inner loop - i=' & i & '<br />');
}
}
}
You might expect the following output from that code:
But you'd actually get this:
That's because the inner loop overrides the assignment of 'i'. When the inner loop completes and the outer loop proceeds it realizes that 'i' is no longer less then or equal to 3 and it stops processing.
The lesson here is to be careful with your var scoping. You'll no longer get the luxury of ColdFusion telling you that a local variable can not be declared more then once. Also, remember the importance of variable naming. You won't get an error but you could end up with some seriously unexpected results.