Fix Trac #4099: better error message for type functions