Skip to content

fix: strip hypothesis-naming metadata from proof-mode targets#13812

Merged
sgraf812 merged 3 commits into
masterfrom
sgraf-mhave-mdata-fix
May 21, 2026
Merged

fix: strip hypothesis-naming metadata from proof-mode targets#13812
sgraf812 merged 3 commits into
masterfrom
sgraf-mhave-mdata-fix

Conversation

@sgraf812
Copy link
Copy Markdown
Contributor

This PR fixes mconstructor, mleft, and mright failing inside mhave blocks (#13691), and mspecialize failing after a mrevert; mintro round trip. Both cases stem from hypothesis-naming Expr.mdata leaking from hypothesis-conjunction leaves into non-leaf positions (an inner target, or the antecedent of an SPred.imp target), where downstream pattern matches did not see through it.

Fixed by stripping the mdata at the offending non-leaf positions in elabMHave, elabMReplace, and mRevert.

This PR fixes `mconstructor`, `mleft`, and `mright` failing inside `mhave`
blocks, as well as `mspecialize` failing after a `mrevert; mintro` round
trip. In both cases the inner proof state carried stray hypothesis-naming
metadata that downstream tactics' pattern matches did not see through.

`elabMHave` and `elabMReplace` placed `hyp.toExpr` (mdata-wrapped) as the
inner `haveGoal`'s target; `mRevert` placed the focused hypothesis into
the antecedent of the new `SPred.imp` target with mdata still attached,
which then got captured into `Hyp.p` by the next `mintro`. Use the raw
expression (or `consumeMData`) at those non-hypothesis-leaf positions so
the invariant "hyp-naming mdata lives only on hypothesis-conjunction
leaves" holds.
@sgraf812 sgraf812 added the changelog-tactics User facing tactics label May 21, 2026
Equivalent change; `Hyp.p` is more semantic than stripping mdata defensively.
@sgraf812 sgraf812 enabled auto-merge May 21, 2026 15:46
CI build broke after the previous refactor because `throwError` cannot be
typechecked directly in the generic monad `m` of `mRevert`; lift it via
`liftMetaM` like the other error sites in this file.
@sgraf812 sgraf812 added this pull request to the merge queue May 21, 2026
Merged via the queue into master with commit ed790e9 May 21, 2026
16 checks passed
@sgraf812 sgraf812 deleted the sgraf-mhave-mdata-fix branch May 21, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-tactics User facing tactics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant