leanprover / leanprover/lean4

Regression in nightly: type mismatch (4.25.0-nightly-2025-10-10)

Open
#10,736 6 comments 2 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

Please put an X between the brackets as you perform the following steps:

Description

I'm getting some strange errors in Nightly.

Steps to Reproduce
#version -- Lean 4.25.0-nightly-2025-10-10

/-- Similar to `List.ofFnM`, but returns a dependent function rather than `List`. -/
def dfun_ofFnM.{u, v}
    {m : Type u → Type v} [Monad m]
    {n : Nat}
    {α : Fin n → Type u}
    (f : (i : Fin n) → m (α i)) :
    m ((i : Fin n) → α i) :=
  sorry

def compute (n : Nat) (v : Vector Nat n) : Except String Bool := do
  let l : List (String × Nat) := sorry
  let hv /- : (i : Fin n) → PLift (v[i] = v[i]) -/ ← dfun_ofFnM fun (i : Fin n) =>
    have : n = l.length := sorry
    let h : v[i] = v[i] := rfl
    .ok (PLift.up h)
  let hv' : ∀ (i : Nat) (hi : i < n), v[i] = v[i] :=
    fun i hi => (hv ⟨i, hi⟩).down -- ERROR
/-
Type mismatch
  (hv ⟨i, hi⟩).down
has type
  ?m.83 ⟨i, hi⟩
but is expected to have type
  v[i] = v[i]
-/
  .ok true

Expected behavior: No error, as in 4.24.0-rc1.

Actual behavior: Error, with a lot of strangeness:

  • Uncommenting the type annotation eliminates the error.
  • Deleting have : n = l.length := sorry (which is unused) eliminates the error.
  • Changing l from a local variable to a parameter eliminates the error.

Also, I'm getting a warning "declaration uses 'sorry'" at a strange location -- it's for the first "v[i]" on the line let h : v[i] = v[i].

Versions

Lean 4.25.0-nightly-2025-10-10

Impact

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

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 self-contained reproducer from the issue against Lean 4.25.0-nightly-2025-10-10 and 4.24.0-rc1, focusing on dfun_ofFnM and compute. Done means the nightly version accepts the example without the type mismatch or misplaced sorry warning, while preserving the reported behavior.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.