improve error message for impossible function invocation