feat(frontends/lean/pp): improve let-expr pretty printer
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
2ce92feae1
commit
d8548369e7
4 changed files with 21 additions and 2 deletions
|
@ -1097,9 +1097,10 @@ public:
|
||||||
return p->first;
|
return p->first;
|
||||||
} else {
|
} else {
|
||||||
auto ecs = visit(get_annotation_arg(e));
|
auto ecs = visit(get_annotation_arg(e));
|
||||||
m_cache.insert(e, mk_pair(ecs.first, ecs.second));
|
expr r = copy_tag(ecs.first, mk_let_value_annotation(ecs.first));
|
||||||
|
m_cache.insert(e, mk_pair(r, ecs.second));
|
||||||
cs += ecs.second;
|
cs += ecs.second;
|
||||||
return ecs.first;
|
return r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -324,6 +324,7 @@ static bool is_show(expr const & e) {
|
||||||
return is_show_annotation(e) && is_app(get_annotation_arg(e)) &&
|
return is_show_annotation(e) && is_app(get_annotation_arg(e)) &&
|
||||||
is_lambda(app_fn(get_annotation_arg(e)));
|
is_lambda(app_fn(get_annotation_arg(e)));
|
||||||
}
|
}
|
||||||
|
static bool is_let_value(expr const & e) { return is_let_value_annotation(e); }
|
||||||
|
|
||||||
auto pretty_fn::pp_have(expr const & e) -> result {
|
auto pretty_fn::pp_have(expr const & e) -> result {
|
||||||
expr proof = app_arg(e);
|
expr proof = app_arg(e);
|
||||||
|
@ -430,6 +431,7 @@ auto pretty_fn::pp(expr const & e) -> result {
|
||||||
if (is_have(e)) return pp_have(e);
|
if (is_have(e)) return pp_have(e);
|
||||||
if (is_let(e)) return pp_let(e);
|
if (is_let(e)) return pp_let(e);
|
||||||
if (is_typed_expr(e)) return pp(get_typed_expr_expr(e));
|
if (is_typed_expr(e)) return pp(get_typed_expr_expr(e));
|
||||||
|
if (is_let_value(e)) return pp(get_annotation_arg(e));
|
||||||
if (auto n = to_num(e)) return pp_num(*n);
|
if (auto n = to_num(e)) return pp_num(*n);
|
||||||
if (!m_metavar_args && is_meta(e))
|
if (!m_metavar_args && is_meta(e))
|
||||||
return pp_meta(get_app_fn(e));
|
return pp_meta(get_app_fn(e));
|
||||||
|
|
15
tests/lean/let3.lean
Normal file
15
tests/lean/let3.lean
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import data.num
|
||||||
|
using num
|
||||||
|
|
||||||
|
variable f : num → num → num → num
|
||||||
|
|
||||||
|
check
|
||||||
|
let a := 10
|
||||||
|
in f a 10
|
||||||
|
|
||||||
|
/-
|
||||||
|
check
|
||||||
|
let a := 10,
|
||||||
|
b := 10
|
||||||
|
in f a b 10
|
||||||
|
-/
|
1
tests/lean/let3.lean.expected.out
Normal file
1
tests/lean/let3.lean.expected.out
Normal file
|
@ -0,0 +1 @@
|
||||||
|
let a := 10 in f a 10 : num → num
|
Loading…
Reference in a new issue