This PR fixes an issue reported [on Zulip](https://leanprover.zulipchat.com/#narrow/channel/239415-metaprogramming-.2F-tactics/topic/.60abstractMVars.60.20not.20instantiating.20level.20mvars/near/541918246) where `abstractMVars` (which is used in typeclass inference and `simp` argument elaboration) was not instantiating metavariables in the types of metavariables, causing it to abstract already-assigned metavariables. This also eliminates an unnecessary `instantiateMVars` and documents the invariant that the argument to `abstractExprMVars` must have its metavariables already instantiated.
23 lines
778 B
Text
23 lines
778 B
Text
import Lean
|
|
/-!
|
|
# Tests of the `Lean.Meta.abstractMVars` procedure
|
|
-/
|
|
|
|
open Lean Meta
|
|
|
|
/-!
|
|
The following example used to abstract `levelMVar` even though it was assigned.
|
|
The issue was that the procedure failed to instantiateMVars in the types of metavariables.
|
|
|
|
Reported on Zulip: https://leanprover.zulipchat.com/#narrow/channel/239415-metaprogramming-.2F-tactics/topic/.60abstractMVars.60.20not.20instantiating.20level.20mvars/near/541918246
|
|
-/
|
|
|
|
/-- info: [] -/
|
|
#guard_msgs in
|
|
run_meta
|
|
let levelMVar ← mkFreshLevelMVar
|
|
let mvar ← mkFreshExprMVar (some (mkSort levelMVar))
|
|
discard <| isDefEq (mkSort levelMVar) (mkSort (mkLevelParam `u))
|
|
let mvar ← instantiateMVars mvar
|
|
let abstractResult ← abstractMVars mvar
|
|
Lean.logInfo m!"{abstractResult.paramNames}"
|