fix: Collect errored mvars by iterating errorInfo

This commit is contained in:
Leni Aniva 2024-12-10 23:16:33 -08:00
parent d040d2006c
commit 1d10cd2b20
Signed by: aniva
GPG Key ID: 4D9B1C8D10EA4C50
1 changed files with 17 additions and 4 deletions

View File

@ -177,12 +177,25 @@ protected def GoalState.getMVarEAssignment (goalState: GoalState) (mvarId: MVarI
--- Tactic execution functions --- --- Tactic execution functions ---
-- Mimics `Elab.Term.logUnassignedUsingErrorInfos`
private def collectAllErroredMVars (src : MVarId) : Elab.TermElabM (List MVarId) := do private def collectAllErroredMVars (src : MVarId) : Elab.TermElabM (List MVarId) := do
let descendants ← Meta.getMVars $ ← instantiateMVars (.mvar src) let descendants ← Meta.getMVars $ ← instantiateMVars (.mvar src)
(← getThe Elab.Term.State).mvarErrorInfos let mut alreadyVisited : MVarIdSet := {}
|>.map (·.mvarId) let mut result : MVarIdSet := {}
|>.filterM λ mvarId => for mvarErrorInfo in (← get).mvarErrorInfos do
return descendants.contains mvarId ∧ !(← mvarId.isAssignedOrDelayedAssigned) let mvarId := mvarErrorInfo.mvarId
unless alreadyVisited.contains mvarId do
alreadyVisited := alreadyVisited.insert mvarId
/- The metavariable `mvarErrorInfo.mvarId` may have been assigned or
delayed assigned to another metavariable that is unassigned. -/
let mvarDeps ← Meta.getMVars (mkMVar mvarId)
if mvarDeps.any descendants.contains then do
result := result.insert mvarId
return result.toList
--(← getThe Elab.Term.State).mvarErrorInfos
-- |>.map (·.mvarId)
-- |>.filterM λ mvarId =>
-- return descendants.contains mvarId ∧ !(← mvarId.isAssignedOrDelayedAssigned)
private def mergeMVarLists (li1 li2 : List MVarId) : List MVarId := private def mergeMVarLists (li1 li2 : List MVarId) : List MVarId :=
let li2' := li2.filter (¬ li1.contains ·) let li2' := li2.filter (¬ li1.contains ·)