Fix ICE (issue 8262).
Add test case.