Try to produce better error messages when we can't distinguish between a function call and a type cast. Fixes #2902