Hi Dmitry,
thanks for the proposal
some generic comments though:
you're in fact tackling two different issues:
* %1 as FOR loop variable * FOR variables' expansion in nested FOR loops
I think it would be simpler to separate the two (even if the two are needed to fix the mentioned bug). This could be kept in a single MR (4 commits: test for %1 in loop, fix for %1 in loop, test for expansion in nested loops) or spread across two.
I'll post also some more detailed comments in the commits.