fix(library/aliases): namespace and constant have the same name, and 'using' produces the 'empty' alias

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2014-08-07 08:24:56 -07:00
parent 4ad7e709aa
commit 955d7d2659
2 changed files with 5 additions and 3 deletions

View file

@ -184,7 +184,7 @@ auto pretty_fn::pp_const(expr const & e) -> result {
for (name const & ns : get_namespaces(m_env)) {
if (!ns.is_anonymous()) {
name new_n = n.replace_prefix(ns, name());
if (new_n != n) {
if (new_n != n && !new_n.is_anonymous()) {
n = new_n;
break;
}

View file

@ -188,7 +188,8 @@ environment add_aliases(environment const & env, name const & prefix, name const
env.for_each_declaration([&](declaration const & d) {
if (is_prefix_of(prefix, d.get_name()) && !is_exception(d.get_name(), prefix, num_exceptions, exceptions)) {
name a = d.get_name().replace_prefix(prefix, new_prefix);
ext.add_expr_alias(a, d.get_name());
if (!a.is_anonymous())
ext.add_expr_alias(a, d.get_name());
}
});
env.for_each_universe([&](name const & u) {
@ -196,7 +197,8 @@ environment add_aliases(environment const & env, name const & prefix, name const
name a = u.replace_prefix(prefix, new_prefix);
if (env.is_universe(a))
throw exception(sstream() << "universe level alias '" << a << "' shadows existing global universe level");
ext.add_level_alias(a, u);
if (!a.is_anonymous())
ext.add_level_alias(a, u);
}
});
return update(env, ext);