Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Lean/Meta/WrapInstance.lean
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public import Lean.Meta.SynthInstance
public import Lean.Meta.CtorRecognizer
public import Lean.Meta.AppBuilder
import Lean.Structure
import Lean.ExtraModUses

/-!
# Instance Wrapping
Expand Down Expand Up @@ -133,6 +134,10 @@ public partial def wrapInstance (inst expectedType : Expr) (compile : Bool := tr
else
return inst

-- record inferred instance as elab dependency before `whnf` may remove it
if let .const n .. := inst.getAppFn then
recordExtraModUseFromDecl n isMeta

-- Try to reduce it to a constructor.
(← whnf inst).withApp fun f args => do
let some (.ctorInfo ci) ← f.constName?.mapM getConstInfo
Expand Down
13 changes: 13 additions & 0 deletions tests/elab/extraModUses.lean
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,16 @@ info: Entries: [public import Init.Tactics]
Is rev mod use: false
-/
#guard_msgs in #eval showExtraModUses

/-! `inferInstanceAs` inputs not included in output. -/

#eval resetExtraModUses

def MyNat := Nat
instance : Max MyNat := inferInstanceAs (Max Nat)

/--
info: Entries: [import Init.Data.Nat.Basic]
Is rev mod use: false
-/
#guard_msgs in #eval showExtraModUses
Loading