What's wrong with this 'cast to'?

Don’t worry, I managed to figure it out eventually.