Handle nested blocks in loops correctly (#14097)

Change-Id: I27a0a976d32a81390c6445c366afa4a08a476db7