feat: add elabTermAndSynthesize auxiliary method
Useful for creating "checkpoints".
This commit is contained in:
parent
81a7cf50d3
commit
c10230ec0a
1 changed files with 12 additions and 0 deletions
|
|
@ -211,6 +211,18 @@ private partial def synthesizeSyntheticMVarsAux (mayPostpone := true) : Unit →
|
|||
def synthesizeSyntheticMVars (mayPostpone := true) : TermElabM Unit :=
|
||||
synthesizeSyntheticMVarsAux mayPostpone ()
|
||||
|
||||
/-- Elaborate `stx`, and make sure all pending synthetic metavariables created while elaborating `stx` are solved. -/
|
||||
def elabTermAndSynthesize (stx : Syntax) (expectedType? : Option Expr) : TermElabM Expr := do
|
||||
s ← get;
|
||||
let syntheticMVars := s.syntheticMVars;
|
||||
modify $ fun s => { syntheticMVars := [], .. s };
|
||||
finally
|
||||
(do
|
||||
v ← elabTerm stx expectedType?;
|
||||
synthesizeSyntheticMVars false;
|
||||
instantiateMVars stx v)
|
||||
(modify $ fun s => { syntheticMVars := s.syntheticMVars ++ syntheticMVars, .. s })
|
||||
|
||||
end Term
|
||||
end Elab
|
||||
end Lean
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue