Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - fix(frontends/lean/pp): correct binder links #781

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/frontends/lean/pp.cpp
Original file line number Diff line number Diff line change
@@ -1623,11 +1623,11 @@ static T mk_tk_fmt(name const & tkn) {
}
}
template<class T>
auto pretty_fn<T>::pp_notation(notation_entry const & entry, buffer<optional<subexpr>> & args) -> optional<result> {
auto pretty_fn<T>::pp_notation(notation_entry const & entry, expr const & src, buffer<optional<subexpr>> & args) -> optional<result> {
if (entry.is_numeral()) {
return some(result(T(entry.get_num().to_string())));
} else if (is_atomic_notation(entry)) {
T fmt = mk_link(entry.get_expr(), T(head(entry.get_transitions()).get_token().to_string_unescaped()));
T fmt = mk_link(src, T(head(entry.get_transitions()).get_token().to_string_unescaped()));
return some(result(fmt));
} else {
using notation::transition;
@@ -1646,7 +1646,7 @@ auto pretty_fn<T>::pp_notation(notation_entry const & entry, buffer<optional<sub
T curr;
notation::action const & a = ts[i].get_action();
name const & tk = ts[i].get_token();
T tk_fmt = mk_link(entry.get_expr(), mk_tk_fmt<T>(ts[i].get_pp_token().to_string_unescaped()));
T tk_fmt = mk_link(src, mk_tk_fmt<T>(ts[i].get_pp_token().to_string_unescaped()));
switch (a.kind()) {
case notation::action_kind::Skip:
curr = tk_fmt;
@@ -1828,7 +1828,7 @@ auto pretty_fn<T>::pp_notation(subexpr const & ep) -> optional<result> {
buffer<optional<subexpr>> args;
args.resize(num_params);
if (match(entry.get_expr(), ep, args)) {
if (auto r = pp_notation(entry, args))
if (auto r = pp_notation(entry, ep.first, args))
return r;
}
}
2 changes: 1 addition & 1 deletion src/frontends/lean/pp.h
Original file line number Diff line number Diff line change
@@ -136,7 +136,7 @@ class pretty_fn {
bool match(expr const & p, subexpr const & e, buffer<optional<subexpr>> & args);
/** \brief pretty-print e parsed with rbp, terminated by a token with lbp */
result pp_notation_child(expr const & e, unsigned rbp, unsigned lbp, bool below_implicit = false);
optional<result> pp_notation(notation_entry const & entry, buffer<optional<subexpr>> & args);
optional<result> pp_notation(notation_entry const & entry, expr const & e, buffer<optional<subexpr>> & args);
optional<result> pp_notation(subexpr const & e);

result add_paren_if_needed(result const & r, unsigned bp);
6 changes: 5 additions & 1 deletion tests/lean/pp_links.lean
Original file line number Diff line number Diff line change
@@ -5,4 +5,8 @@ structure point (α : Type*) :=

example : ∀ i : ℤ, (i, i).snd = i + 0 + (point.mk 0 i).x := by do
os ← get_options,
set_options (os.set_bool `pp.links tt)
set_options (os.set_bool `pp.links tt)

example : ∃ i j : ℤ, true := by do
os ← get_options,
set_options (os.set_bool `pp.links tt)
3 changes: 3 additions & 0 deletions tests/lean/pp_links.lean.expected.out
Original file line number Diff line number Diff line change
@@ -4,3 +4,6 @@ state:
(i, i).prod.sndsndeq =
ihas_add.add + 0has_add.add +
point.mk{point.xx := 0, point.yy := i}.point.xx
pp_links.lean:10:32: error: tactic failed, there are unsolved goals
state:
⊢ Exists∃ (i j : intℤ)Exists, truetrue