Skip to content

feat: add pretty printer flag to instantiate non-ground delayed assignments#12393

Open
sgraf812 wants to merge 1 commit intomasterfrom
sg/pp-non-ground
Open

feat: add pretty printer flag to instantiate non-ground delayed assignments#12393
sgraf812 wants to merge 1 commit intomasterfrom
sg/pp-non-ground

Conversation

@sgraf812
Copy link
Contributor

@sgraf812 sgraf812 commented Feb 9, 2026

This PR adds an opt-in pretty printing flag pp.mvars.delayedNonGround that takes effect when pp.mvars.delayed is false.
Recall that instantiateMVars does not instantiate a delayed assigned MVar if the assignment is non-ground (i.e., contains metavariables itself). This flag opts into doing the instantiation while pretty printing. Example:

set_option pp.mvars.delayedNonGround false in -- the default
/--
error: Invalid match expression: The type of pattern variable 'a' contains metavariables:
  ?m.12
---
info: fun x => ?m.3 : ?m.12 × ?m.13 → ?m.12
-/
#guard_msgs in
#check fun (a, b) => a

set_option pp.mvars.delayedNonGround true in -- opt in
/--
error: Invalid match expression: The type of pattern variable 'a' contains metavariables:
  ?m.12
---
info: fun x => sorry : ?m.12 × ?m.13 → ?m.12
-/
#guard_msgs in
#check fun (a, b) => a

This flag is most useful for debugging metaprograms that create synthetic opaque metavariables and assign those to non-ground solutions. It happens regularly that incomplete instantiation leads debugging sessions down the wrong path.

@sgraf812 sgraf812 requested a review from kmill as a code owner February 9, 2026 14:50
@sgraf812 sgraf812 added the changelog-language Language features and metaprograms label Feb 9, 2026
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-language Language features and metaprograms toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant