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

Bug in widgets: type of i in ∃ i, ... is wrong #1618

Closed
jcommelin opened this issue Sep 17, 2022 · 2 comments · Fixed by #3797
Closed

Bug in widgets: type of i in ∃ i, ... is wrong #1618

jcommelin opened this issue Sep 17, 2022 · 2 comments · Fixed by #3797

Comments

@jcommelin
Copy link
Contributor

Description

In the widget view, if you hover over the i in ∃ i, ... it doesn't show the type of i, but the type of the lambda that goes into the existential. Hover in the source code window works as expected.

Steps to Reproduce

Consider

example {α : Type} (h : ∃i : α, i = i) : True :=
by
  trivial

and put your cursor between by and trivial.

Now hover over the i that follows , both in the source code window and in the infoview.

Expected behavior:

If you hover over the corresponding i in the source window, you get i : α in the popup

Actual behavior:

Now hover over the i that follows , in the info view. I would expect the type i : α to show up. But instead the type of the lambda that is part of the is shown.

Reproduces how often:

100%

Versions

Lean (version 4.0.0-nightly-2022-09-11, commit 1749210, Release)
Linux (NixOS unstable)

@leodemoura
Copy link
Member

image

@EdAyers
Copy link
Contributor

EdAyers commented Sep 18, 2022

Also true for all other kinds of binder. I think the problem is in withBindingBodyUnusedName in src/lean/prettyprinter/delaborator/basic.lean.

We are annotating the i with the subexpr position of the parent expression.
Unfortunately with the way that delaborator works it might not be super-easy to fix this; since there is no subexpr position that would produce the i : α output. Using the binding domain position gives α : Type which is a little confusing.

One way to fix this is to modify SubExpr.Pos to also include a new coordinate value that says we want to report the newly made bound variable.

github-merge-queue bot pushed a commit that referenced this issue Mar 29, 2024
Modifies `withBindingBodyUnusedName` to annotate the syntax for the
variable with its corresponding fvar. Now, for example, you can hover
over the variables in `fun x y => ...` in the infoview to see their
types. This change affects notations such as `∃ n, n = 1`, where
hovering over `n` shows that `n : Nat`.

Also adds such annotations for the variables in `let` and `let_fun`.

Implementation note: the variables are annotated with fresh positions
using `nextExtraPos`.

Removes the unused and unnecessary
`Lean.PrettyPrinter.Delaborator.liftMetaM`.

Closes #1618, closes #2737
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants