feat(library/aliases): remove duplicates from aliasing tables
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
a84107db3d
commit
6ceecf6a15
3 changed files with 31 additions and 1 deletions
|
@ -35,7 +35,7 @@ struct aliases_ext : public environment_extension {
|
|||
void add_alias(name const & a, expr const & e) {
|
||||
auto it = m_state.m_aliases.find(a);
|
||||
if (it)
|
||||
m_state.m_aliases.insert(a, list<expr>(e, *it));
|
||||
m_state.m_aliases.insert(a, list<expr>(e, filter(*it, [&](expr const & t) { return t != e; })));
|
||||
else
|
||||
m_state.m_aliases.insert(a, list<expr>(e));
|
||||
m_state.m_inv_aliases.insert(e, a);
|
||||
|
|
25
tests/lean/alias.lean
Normal file
25
tests/lean/alias.lean
Normal file
|
@ -0,0 +1,25 @@
|
|||
import logic
|
||||
|
||||
namespace N1
|
||||
variable num : Type.{1}
|
||||
variable foo : num → num → num
|
||||
end
|
||||
|
||||
namespace N2
|
||||
variable val : Type.{1}
|
||||
variable foo : val → val → val
|
||||
end
|
||||
|
||||
using N2
|
||||
using N1
|
||||
variables a b : num
|
||||
print raw foo a b
|
||||
using N2
|
||||
print raw foo a b
|
||||
using N1
|
||||
print raw foo a b
|
||||
using N1
|
||||
print raw foo a b
|
||||
using N2
|
||||
print raw foo a b
|
||||
|
5
tests/lean/alias.lean.expected.out
Normal file
5
tests/lean/alias.lean.expected.out
Normal file
|
@ -0,0 +1,5 @@
|
|||
(choice N1.foo N2.foo) a b
|
||||
(choice N2.foo N1.foo) a b
|
||||
(choice N1.foo N2.foo) a b
|
||||
(choice N1.foo N2.foo) a b
|
||||
(choice N2.foo N1.foo) a b
|
Loading…
Reference in a new issue