I could not find this rule in the docs.
Neither could I, which was what got me thinking.
This is compiler, and so FPC 3.0.4, and older Lazaruses based on 3.0.4 should react the same.
Strictly speaking it is not an error, since the innermost i is clearly meant, so that should be ok. However even while legal, it is kind of obfuscating.
You're right, of course: compiler, not Lazarus. But I had never seen it before. Not that I make a rule of using index vars like that, but I'm almost sure I've used that "style" some other times (in tests, probably) without problems. Rather curious, in fact.
Note that the inner
i's were added
because the error. In fact, after I added the
var i: Integer to all those nested procs I got a
Warning: variable "i" never used ("anymore" I would have added
) for the outer one.
It's not that it matters much. Just one of those things you have to keep in the background of your mind while coding until they become automatic. But it wold be nice if it were mentioned in the docs, say in the Language Reference for example. In the meantime I'll see if I can add a note in the wiki page.