Fix Issue 9570 - Wrong foreach index implicit conversion error