Skip to content

variable may cause sorry #14718

Description

@thorimur

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 _ _ => trueprivate 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions