Skip to content

Commit 425c494

Browse files
committed
fix(Tactic/Recall): allow different universe variable names (leanprover-community#37145)
Fixes leanprover-community#37144 This PR fixes `recall` failing when the recalled declaration uses a different universe variable name (or `Type*`) compared to the original declaration. The type-only branch of `recall` compared `info.type` directly against the elaborated type without first instantiating the original declaration's level parameters with fresh level metavariables. The value branch already did this correctly. 🤖 Prepared with Claude Code
1 parent 51391b2 commit 425c494

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

Mathlib/Tactic/Recall.lean

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ elab_rules : command
8888
Term.synthesizeSyntheticMVarsNoPostponing
8989
let type ← mkForallFVars xs type
9090
let type ← mkForallFVars vars type (usedOnly := true)
91-
unless (← isDefEq info.type type) do
91+
let infoType ← do
92+
let mvs ← info.levelParams.mapM fun _ => mkFreshLevelMVar
93+
pure <| info.type.instantiateLevelParams info.levelParams mvs
94+
unless (← isDefEq infoType type) do
9295
throwTypeMismatchError none info.type type declConst
9396
else
9497
unless binders.getNumArgs == 0 do

MathlibTest/Recall.lean

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,15 @@ recall Nat.add_comm (n m : Nat) : n + m = m + n
100100
-- Test that the unused variable linter does not fire on `recall`.
101101
#guard_msgs in
102102
recall Eq.symm {α : Sort _} {a b : α} (h : a = b) : b = a
103+
104+
-- Test that `recall` works with different universe variable names (issue #37144).
105+
universe u v
106+
class RecallUnivTest (R : Type u) : Prop where
107+
test : True
108+
109+
set_option linter.unusedVariables false in
110+
recall RecallUnivTest (R : Type v) : Prop
111+
112+
-- Test that `recall` works with `Type*`.
113+
set_option linter.unusedVariables false in
114+
recall RecallUnivTest (R : Type*) : Prop

0 commit comments

Comments
 (0)