leanprover / leanprover/lean4

"failed to synthesize GetElem?" with `of_getElem?_eq_some`

Open
#10,592 0 comments 0 reactions 0 assignees View on GitHub

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
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.