Prerequisites
Description
Using variable for a binder may cause an otherwise-silent sorry in private declarations using private constants.
Context
The following example was found when using non-publicly importing the real-life versions of A, B, and the instances in a test file.
I suspect that this is related to #14708, but may have to do specifically with what isExporting setting is provided to runTermElabM in elabMutualDef. (This is just a hunch.)
Steps to Reproduce
module
public section
private def A := Bool
private def B := Bool
private instance : Coe A B := ⟨id⟩
private instance : Membership Bool A := ⟨fun _ _ => true⟩
private def l (s : A) : A := s
axiom notSorry {α} : α
variable (s : A)
/-- warning: declaration uses `sorry` -/
#guard_msgs in
private theorem bad {a : Bool} : a ∈ l s := notSorry
/-- info: bad {a : Bool} : a ∈ l sorry -/
#guard_msgs in
#check bad
private theorem good {a : Bool} (s : A) : a ∈ l s := notSorry
I would expect bad to behave like good. (Apologies, this is minimized from a real example, and I don't have a generic procedure.)
Note: removing public section or making the definitions public/exposed fixes bad.
Versions
4.34.0-nightly-2026-08-08, web
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
Prerequisites
https://github.com/leanprover/lean4/issues
Avoid dependencies to Mathlib or Batteries.
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
Using
variablefor a binder may cause an otherwise-silentsorryin private declarations using private constants.Context
The following example was found when using non-publicly importing the real-life versions of
A,B, and the instances in a test file.I suspect that this is related to #14708, but may have to do specifically with what
isExportingsetting is provided torunTermElabMinelabMutualDef. (This is just a hunch.)Steps to Reproduce
I would expect
badto behave likegood. (Apologies, this is minimized from a real example, and I don't have a generic procedure.)Note: removing
public sectionor making the definitions public/exposed fixesbad.Versions
4.34.0-nightly-2026-08-08, web
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.