fix(frontends/lean/frontend): is_coercion for environment objects that have parents
Bug was exposed by tests/lua/coercion_bug1.lua Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
2a80807fef
commit
3ea09daf44
2 changed files with 27 additions and 1 deletions
|
@ -339,7 +339,10 @@ struct lean_extension : public environment::extension {
|
|||
}
|
||||
|
||||
bool is_coercion(expr const & f) const {
|
||||
return m_coercion_set.find(f) != m_coercion_set.end();
|
||||
if (m_coercion_set.find(f) != m_coercion_set.end())
|
||||
return true;
|
||||
lean_extension const * parent = get_parent();
|
||||
return parent && parent->is_coercion(f);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
23
tests/lua/coercion_bug1.lua
Normal file
23
tests/lua/coercion_bug1.lua
Normal file
|
@ -0,0 +1,23 @@
|
|||
local env = environment()
|
||||
|
||||
parse_lean_cmds([[
|
||||
Variable f : Int -> Int -> Int
|
||||
Notation 20 _ +++ _ : f
|
||||
Show f 10 20
|
||||
Notation 20 _ --- _ : f
|
||||
Show f 10 20
|
||||
]], env)
|
||||
|
||||
local F = parse_lean('f 10 20', env)
|
||||
print(lean_formatter(env)(F))
|
||||
assert(tostring(lean_formatter(env)(F)) == "10 --- 20")
|
||||
|
||||
local child = env:mk_child()
|
||||
|
||||
parse_lean_cmds([[
|
||||
Show f 10 20
|
||||
]], child)
|
||||
|
||||
assert(tostring(lean_formatter(env)(F)) == "10 --- 20")
|
||||
print(lean_formatter(child)(F))
|
||||
assert(tostring(lean_formatter(child)(F)) == "10 --- 20")
|
Loading…
Reference in a new issue