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

Mixing binder updates and variable declarations gives confusing errors #2789

Closed
1 task done
eric-wieser opened this issue Oct 30, 2023 · 1 comment
Closed
1 task done
Labels
bug Something isn't working

Comments

@eric-wieser
Copy link
Contributor

eric-wieser commented Oct 30, 2023

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • Check that your issue is not already filed.
    • Reduce the issue to a minimal, self-contained, reproducible test case. Avoid dependencies to mathlib4 or std4.

Description

The variable command is used both to declare new variables, and to update the binder type (implicit / explicit / instance implicit) of existing variables.

Using both features at the same time can produce error messages that advise the user to make things even worse

Context

Zulip thread

Steps to Reproduce

Run the following code

class one (A : Nat)
class two (A : Nat) [one A] := t : Nat

variable (A : Nat) [one A]

section fails
variable {A} [two A]
/-
failed to synthesize instance
  one A
-/
end fails

section bad_advice
-- ok, the error told me to write `one A` again I guess
variable {A} [one A] [two A]

example : True := 
  -- put your cursor here; now `one A` is here twice!
  trivial

end bad_advice

section works
variable {A} [two (by exact A)]
end works

section also_works
variable {A}
variable [two A]
end also_works

Expected behavior: The section fails should either succeed, or it should emit an error message that does not encourage me to write section bad_advice. If you put your cursor at the exact, A should appear once in the goal view.
Actual behavior: The error message tricks me into making a mess of duplicate variables. Putting the cursor at exact shows A twice (as there are two copies!).

Versions

4.2.0-rc4 on the web editor

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@eric-wieser eric-wieser added the bug Something isn't working label Oct 30, 2023
mathlib-bors bot pushed a commit to leanprover-community/mathlib4 that referenced this issue Aug 7, 2024
Make sure to perform binder annotation updates and declaring new variables in separate variable commands.
This is currently recommended because of leanprover/lean4#2789: mixing these can yield confusing errors.

Found by a linter in #15400.
bjoernkjoshanssen pushed a commit to leanprover-community/mathlib4 that referenced this issue Sep 9, 2024
Make sure to perform binder annotation updates and declaring new variables in separate variable commands.
This is currently recommended because of leanprover/lean4#2789: mixing these can yield confusing errors.

Found by a linter in #15400.
bjoernkjoshanssen pushed a commit to leanprover-community/mathlib4 that referenced this issue Sep 9, 2024
Make sure to perform binder annotation updates and declaring new variables in separate variable commands.
This is currently recommended because of leanprover/lean4#2789: mixing these can yield confusing errors.

Found by a linter in #15400.
bjoernkjoshanssen pushed a commit to leanprover-community/mathlib4 that referenced this issue Sep 12, 2024
Make sure to perform binder annotation updates and declaring new variables in separate variable commands.
This is currently recommended because of leanprover/lean4#2789: mixing these can yield confusing errors.

Found by a linter in #15400.
@Kha
Copy link
Member

Kha commented Nov 15, 2024

Fixed in #5142

@Kha Kha closed this as completed Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants