better error messages for has/method outside of class block