fix(frontends/lean/pp): pp was not taking into account new namespace name resolution rules, fixes #216

This commit is contained in:
Leonardo de Moura 2014-10-01 11:24:45 -07:00
parent 3657d4c3ab
commit f863d82e69
4 changed files with 27 additions and 1 deletions

View file

@ -274,10 +274,23 @@ auto pretty_fn::pp_sort(expr const & e) -> result {
}
}
optional<name> pretty_fn::is_aliased(name const & n) const {
if (auto it = is_expr_aliased(m_env, n)) {
// must check if we are not shadow by current namespace
for (name const & ns : get_namespaces(m_env)) {
if (!ns.is_anonymous() && m_env.find(ns + *it))
return optional<name>();
}
return it;
} else {
return optional<name>();
}
}
auto pretty_fn::pp_const(expr const & e) -> result {
name n = const_name(e);
if (!m_full_names) {
if (auto it = is_expr_aliased(m_env, n)) {
if (auto it = is_aliased(n)) {
n = *it;
} else {
for (name const & ns : get_namespaces(m_env)) {

View file

@ -54,6 +54,7 @@ private:
bool is_implicit(expr const & f);
bool is_prop(expr const & e);
bool has_implicit_args(expr const & f);
optional<name> is_aliased(name const & n) const;
format pp_binder_block(buffer<name> const & names, expr const & type, binder_info const & bi);
format pp_binders(buffer<expr> const & locals);

11
tests/lean/alias2.lean Normal file
View file

@ -0,0 +1,11 @@
import logic
namespace foo
definition t := true
end foo
open foo
namespace bla
definition t := false
check foo.t -- <<< must print foo.t : Prop instead of t : Prop
end bla

View file

@ -0,0 +1 @@
foo.t : Prop