feat(library/coercion): improve error message when target is unacceptable

This commit is contained in:
Daniel Selsam 2015-08-13 21:11:39 -07:00 committed by Leonardo de Moura
parent f4e1e9d671
commit 5bef45b1fd

View file

@ -341,8 +341,9 @@ static environment add_coercion(environment const & env, name const & f, name co
check_levels(const_levels(C_fn), d.get_univ_params())) {
optional<name> cls = type_to_coercion_class(binding_body(t));
if (!cls)
throw exception(sstream() << "invalid coercion, '" << f << "' cannot be used as a coercion from '"
<< C << "'");
throw exception(sstream() << "invalid coercion, '" << f << "' cannot be used as a coercion from source '"
<< C << "', since target does not match any of the acceptable forms\n"
<< "D t_1 ... t_m\n" << "Type\n" << "Pi x : A, B x\n");
else if (is_user_class(*cls) && *cls == C)
throw exception(sstream() << "invalid coercion, '" << f << "' is a coercion from '" << C << "' to itself");
return add_coercion_core(env, C, f, num, *cls, persistent);