null-ref check.
Foreach iterator variables were not handled correctly when looking up references