feat(library/coercion): improve error message when target is unacceptable
This commit is contained in:
parent
f4e1e9d671
commit
5bef45b1fd
1 changed files with 3 additions and 2 deletions
|
@ -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())) {
|
check_levels(const_levels(C_fn), d.get_univ_params())) {
|
||||||
optional<name> cls = type_to_coercion_class(binding_body(t));
|
optional<name> cls = type_to_coercion_class(binding_body(t));
|
||||||
if (!cls)
|
if (!cls)
|
||||||
throw exception(sstream() << "invalid coercion, '" << f << "' cannot be used as a coercion from '"
|
throw exception(sstream() << "invalid coercion, '" << f << "' cannot be used as a coercion from source '"
|
||||||
<< C << "'");
|
<< 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)
|
else if (is_user_class(*cls) && *cls == C)
|
||||||
throw exception(sstream() << "invalid coercion, '" << f << "' is a coercion from '" << C << "' to itself");
|
throw exception(sstream() << "invalid coercion, '" << f << "' is a coercion from '" << C << "' to itself");
|
||||||
return add_coercion_core(env, C, f, num, *cls, persistent);
|
return add_coercion_core(env, C, f, num, *cls, persistent);
|
||||||
|
|
Loading…
Reference in a new issue