fix(frontends/lean/pp): protect pretty printer from exceptions

This commit is contained in:
Leonardo de Moura 2014-09-18 16:21:20 -07:00
parent b3e05a2fe9
commit 970ad72bc3

View file

@ -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,6 +251,7 @@ 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);
try {
expr type = m_tc.whnf(m_tc.infer(f).first).first; expr type = m_tc.whnf(m_tc.infer(f).first).first;
while (is_pi(type)) { while (is_pi(type)) {
binder_info bi = binding_info(type); binder_info bi = binding_info(type);
@ -260,6 +261,9 @@ bool pretty_fn::has_implicit_args(expr const & f) {
type = m_tc.whnf(instantiate(binding_body(type), local)).first; type = m_tc.whnf(instantiate(binding_body(type), local)).first;
} }
return false; return false;
} catch (exception &) {
return false;
}
} }
auto pretty_fn::pp_app(expr const & e) -> result { auto pretty_fn::pp_app(expr const & e) -> result {