Skip to content

Commit a7efe5b

Browse files
authored
Revert "fix: make sure refine preserves pre-existing natural mvars (leanprover#2435)" (leanprover#2485)
This reverts commit 0b64c1e.
1 parent b8084d5 commit a7efe5b

File tree

3 files changed

+6
-75
lines changed

3 files changed

+6
-75
lines changed

src/Lean/Elab/Tactic/ElabTerm.lean

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,23 +124,21 @@ where
124124
let newMVarIds ← getMVarsNoDelayed val
125125
/- ignore let-rec auxiliary variables, they are synthesized automatically later -/
126126
let newMVarIds ← newMVarIds.filterM fun mvarId => return !(← Term.isLetRecAuxMVar mvarId)
127-
/- The following `unless … do` block guards against unassigned natural mvarids created during
128-
`k` in the case that `allowNaturalHoles := false`. If we pass this block without aborting, we
129-
can be assured that `newMVarIds` does not contain unassigned natural mvars created during `k`.
130-
Note that in all cases we must allow `newMVarIds` to contain unassigned natural mvars which
131-
were created *before* `k`; this is the purpose of `mvarCounterSaved`, which lets us distinguish
132-
mvars created before `k` from those created during and after. See issue #2434. -/
133-
unless allowNaturalHoles do
127+
let newMVarIds ← if allowNaturalHoles then
128+
pure newMVarIds.toList
129+
else
134130
let naturalMVarIds ← newMVarIds.filterM fun mvarId => return (← mvarId.getKind).isNatural
131+
let syntheticMVarIds ← newMVarIds.filterM fun mvarId => return !(← mvarId.getKind).isNatural
135132
let naturalMVarIds ← filterOldMVars naturalMVarIds mvarCounterSaved
136133
logUnassignedAndAbort naturalMVarIds
134+
pure syntheticMVarIds.toList
137135
/-
138136
We sort the new metavariable ids by index to ensure the new goals are ordered using the order the metavariables have been created.
139137
See issue #1682.
140138
Potential problem: if elaboration of subterms is delayed the order the new metavariables are created may not match the order they
141139
appear in the `.lean` file. We should tell users to prefer tagged goals.
142140
-/
143-
let newMVarIds ← sortMVarIdsByIndex newMVarIds.toList
141+
let newMVarIds ← sortMVarIdsByIndex newMVarIds
144142
tagUntaggedGoals (← getMainTag) tagSuffix newMVarIds
145143
return (val, newMVarIds)
146144

tests/lean/refinePreservesNaturalMVars.lean

Lines changed: 0 additions & 53 deletions
This file was deleted.

tests/lean/refinePreservesNaturalMVars.lean.expected.out

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)