fix(frontends/lean/pp): protect pretty printer from exceptions
This commit is contained in:
parent
b3e05a2fe9
commit
970ad72bc3
1 changed files with 14 additions and 10 deletions
|
@ -139,7 +139,7 @@ bool pretty_fn::is_implicit(expr const & f) {
|
||||||
try {
|
try {
|
||||||
binder_info bi = binding_info(m_tc.ensure_pi(m_tc.infer(f).first).first);
|
binder_info bi = binding_info(m_tc.ensure_pi(m_tc.infer(f).first).first);
|
||||||
return bi.is_implicit() || bi.is_strict_implicit();
|
return bi.is_implicit() || bi.is_strict_implicit();
|
||||||
} catch (...) {
|
} catch (exception &) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ bool pretty_fn::is_implicit(expr const & f) {
|
||||||
bool pretty_fn::is_prop(expr const & e) {
|
bool pretty_fn::is_prop(expr const & e) {
|
||||||
try {
|
try {
|
||||||
return m_env.impredicative() && m_tc.is_prop(e).first;
|
return m_env.impredicative() && m_tc.is_prop(e).first;
|
||||||
} catch (...) {
|
} catch (exception &) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,15 +251,19 @@ auto pretty_fn::pp_local(expr const & e) -> result {
|
||||||
static name g_tmp_prefix = name::mk_internal_unique_name();
|
static name g_tmp_prefix = name::mk_internal_unique_name();
|
||||||
bool pretty_fn::has_implicit_args(expr const & f) {
|
bool pretty_fn::has_implicit_args(expr const & f) {
|
||||||
name_generator ngen(g_tmp_prefix);
|
name_generator ngen(g_tmp_prefix);
|
||||||
expr type = m_tc.whnf(m_tc.infer(f).first).first;
|
try {
|
||||||
while (is_pi(type)) {
|
expr type = m_tc.whnf(m_tc.infer(f).first).first;
|
||||||
binder_info bi = binding_info(type);
|
while (is_pi(type)) {
|
||||||
if (bi.is_implicit() || bi.is_strict_implicit())
|
binder_info bi = binding_info(type);
|
||||||
return true;
|
if (bi.is_implicit() || bi.is_strict_implicit())
|
||||||
expr local = mk_local(ngen.next(), binding_name(type), binding_domain(type), binding_info(type));
|
return true;
|
||||||
type = m_tc.whnf(instantiate(binding_body(type), local)).first;
|
expr local = mk_local(ngen.next(), binding_name(type), binding_domain(type), binding_info(type));
|
||||||
|
type = m_tc.whnf(instantiate(binding_body(type), local)).first;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} catch (exception &) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pretty_fn::pp_app(expr const & e) -> result {
|
auto pretty_fn::pp_app(expr const & e) -> result {
|
||||||
|
|
Loading…
Add table
Reference in a new issue