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

Structure update notation falls over optional parameters #5406

Closed
nomeata opened this issue Sep 20, 2024 · 1 comment · Fixed by #5528
Closed

Structure update notation falls over optional parameters #5406

nomeata opened this issue Sep 20, 2024 · 1 comment · Fixed by #5528
Labels
bug Something isn't working P-medium We may work on this issue if we find the time

Comments

@nomeata
Copy link
Contributor

nomeata commented Sep 20, 2024

Description

In the following code, I’d expect { m with a := id } to work, but the elaboration falls over copying the other field over.

structure Methods where
  a : Int → Int
  b : Nat → (opt : Nat := 42) → Nat


/--
error: type mismatch
  fun a => m.b a
has type
  Nat → Nat : Type
but is expected to have type
  Nat → optParam Nat 42 → Nat : Type
-/
#guard_msgs in
def f (m : Methods) : Methods := { m with a := id }

/--
error: type mismatch
  fun a => m.b a
has type
  Nat → Nat : Type
but is expected to have type
  Nat → optParam Nat 42 → Nat : Type
-/
#guard_msgs in
def g (m : Methods) : Methods := { m with a := id, b := m.b }

def h (m : Methods) : Methods := { m with a := id, b := @Methods.b m }

Maybe related to #5397?

Versions

4.12.0-nightly-2024-09-19

Impact

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

@nomeata nomeata added the bug Something isn't working label Sep 20, 2024
@Kha
Copy link
Member

Kha commented Sep 20, 2024

(the simplest fix may be to support @m.b if that is generally desirable)

@leanprover-bot leanprover-bot added the P-medium We may work on this issue if we find the time label Sep 20, 2024
kmill added a commit to kmill/lean4 that referenced this issue Sep 30, 2024
Now one can write `@x.f`, `@(x).f`, `@x.1`, `@(x).1`, and so on.

This fixes an issue where structure instance update notation (like `{x with a := a'}`) could fail if the field `a` had a type with implicit, optional, or auto parameters.

Closes leanprover#5406.
github-merge-queue bot pushed a commit that referenced this issue Oct 9, 2024
Now one can write `@x.f`, `@(x).f`, `@x.1`, `@(x).1`, and so on.

This fixes an issue where structure instance update notation (like `{x
with a := a'}`) could fail if the field `a` had a type with implicit,
optional, or auto parameters.

Closes #5406
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-medium We may work on this issue if we find the time
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants