Zulip Chat Archive

Stream: general

Topic: declaration has free variable with v4.25.0-rc2


pandaman (Oct 28 2025 at 13:30):

I got (kernel) declaration has free variables 'insert._proof_2' when upgrading to v4.25.0-rc2. Here is a minimized example:

#eval Lean.versionString

structure SparseSet (n : Nat) where
  count : Nat
  dense : Vector (Fin n) n
  sparse : Vector (Fin n) n
  -- sparse_dense : ∀ i : Fin n, i < count → sparse[dense[i.val].val] = i
  -- le_count : count ≤ n

def insert {n : Nat} (s : SparseSet n) (i : Fin n) : SparseSet n :=
  let count, dense, sparse := s
  have isLt : count < n := sorry
  let dense' := dense.set count i
  have sparse_dense' (j : Fin n) (h : j < count + 1) : sparse[dense'[j]] = j := by
    sorry
  count + 1, dense', sparse

It seems the nightly has already fixed the issue. Will the fix get backported to v4.25.0?

Kim Morrison (Oct 29 2025 at 01:08):

@pandaman, could you try to identify which PR fixed your problem? Without that, there's nothing to backport.

pandaman (Oct 29 2025 at 03:52):

Do we have pre-built compiler artifacts? I can try bisecting them.

Kim Morrison (Oct 29 2025 at 05:07):

Yes, you can set the contents of lean-toolchain to e.g. leanprover/lean4:nightly-2025-10-27. These form a linear chain, so should be bisectable. (Although not out-of-the-box by git bisect.)

For individual PRs, there is usually, but not always, a toolchain available of the form leanprover/lean4-pr-releases:pr-release-10967.

pandaman (Oct 29 2025 at 14:50):

The issue was introduced by leanprover/lean4:nightly-2025-10-03 and fixed by leanprover/lean4:nightly-2025-10-25. I haven't investigated which commit was the culprit.

Log

Phase 1: Bisecting regression (2025-09-02 to 2025-10-10)

  • [x] leanprover/lean4:nightly-2025-09-02: Build succeeded (sorry is ok)
  • [x] leanprover/lean4:nightly-2025-09-21: Build succeeded (sorry is ok)
  • [x] leanprover/lean4:nightly-2025-09-30: Build succeeded (sorry is ok)
  • [x] leanprover/lean4:nightly-2025-10-02: Build succeeded (sorry is ok)
  • [x] leanprover/lean4:nightly-2025-10-03: Build failed with (kernel) declaration has free variables 'insert._proof_2'
  • [x] leanprover/lean4:nightly-2025-10-05: Build failed with (kernel) declaration has free variables 'insert._proof_2'
  • [x] leanprover/lean4:nightly-2025-10-10: Build failed with (kernel) declaration has free variables 'insert._proof_2'

Phase 2: Bisecting fix (2025-10-10 to 2025-10-27)

  • [x] leanprover/lean4:nightly-2025-10-18: Build failed with (kernel) declaration has free variables 'insert._proof_2'
  • [x] leanprover/lean4:nightly-2025-10-22: Build failed with (kernel) declaration has free variables 'insert._proof_2'
  • [x] leanprover/lean4:nightly-2025-10-24: Build failed with (kernel) declaration has free variables 'insert._proof_2'
  • [x] leanprover/lean4:nightly-2025-10-25: Build succeeded (sorry is ok)
  • [x] leanprover/lean4:nightly-2025-10-26: Build succeeded (sorry is ok)
  • [x] leanprover/lean4:nightly-2025-10-27: Build succeeded (sorry is ok)

Result

Regression introduced on: 2025-10-03 (nightly-2025-10-03)
The fix was introduced on: 2025-10-25 (nightly-2025-10-25)

Markus Himmel (Oct 29 2025 at 14:59):

Commits in 2025-10-03:

Commits in 2025-10-25:

Out of those, lean4#10926 fixes lean4#10705, which has a similar error message.

Markus Himmel (Oct 29 2025 at 15:03):

Yes, the error is fixed on leanprover/lean4-pr-releases:pr-release-10926. So lean4#10926 might be a candidate for backporting to the 4.25 branch.

Kim Morrison (Oct 29 2025 at 22:22):

I've added the backport-v4.25 label. A bot will hopefully do the rest now!

pandaman (Oct 29 2025 at 22:50):

Thank you!

Eric Wieser (Oct 30 2025 at 22:21):

lean4#10954 might also be worth backporting


Last updated: Dec 20 2025 at 21:32 UTC