"failed to synthesize GetElem?" with `of_getElem?_eq_some`
Open
Nobody has claimed this yet.
bug
P-medium
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Prerequisites
- Check that your issue is not already filed:
https://github.com/leanprover/lean4/issues - Reduce the issue to a minimal, self-contained, reproducible test case.
Avoid dependencies to Mathlib or Batteries. - Test your test case against the latest nightly release, for example on
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
I get the above error when I try to use of_getElem?_eq_some. Curiously, using a temporary variable eliminates the error.
Steps to Reproduce
example (l : List String) (i : Nat) (h : l[i]? = some "") : i < l.length :=
of_getElem?_eq_some h
/-
failed to synthesize
GetElem? Nat Nat ?m.14 LT.lt
-/
example (l : List String) (i : Nat) (h : l[i]? = some "") : i < l.length :=
let dummy := of_getElem?_eq_some h
dummy
/- success -/
Expected behavior: No error.
Actual behavior: Error.
Versions
Lean 4.23.0, 4.25.0-nightly-2025-09-26
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the two minimal examples from the issue on Lean 4.23.0 and the referenced nightly, then compare elaboration of the direct and let-bound forms. Done means the direct use of of_getElem?_eq_some elaborates successfully, with a regression test covering the reproducer.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100