Improved tree error reporting on bad type