Fixes: #2131 Check foreach code