Fixes Issue 5969 - Diagnostic on wrong foreach expression should be in
front-end.