Skip to content

Commit

Permalink
warning when projections already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
fpvandoorn committed Dec 30, 2024
1 parent c4263a5 commit 14c4fac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Mathlib/Tactic/Simps/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,10 @@ def getRawProjections (stx : Syntax) (str : Name) (traceIfExists : Bool := false
-- We always print the projections when they already exists and are called by
-- `initialize_simps_projections`.
withOptions (· |>.updateBool `trace.simps.verbose (traceIfExists || ·)) <| do
trace[simps.debug]
projectionsInfo data.2.toList "Already found projection information for structure" str
trace[simps.verbose]
projectionsInfo data.2.toList "The projections for this structure have already been \
initialized by a previous invocation of `initialize_simps_projections` or `@[simps]`.\n\
Generated projections for" str
return data
trace[simps.verbose] "generating projection information for structure {str}."
trace[simps.debug] "Applying the rules {rules}."
Expand Down
10 changes: 10 additions & 0 deletions MathlibTest/Simps.lean
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ def Foo2.Simps.elim (α : Type _) : Foo2 α → α × α := fun x ↦ (x.elim.1,

initialize_simps_projections Foo2


/--
info: [simps.verbose] The projections for this structure have already been initialized by a previous invocation of `initialize_simps_projections` or `@[simps]`.
Generated projections for Foo2:
Projection elim: fun α x => (x.elim.1, x.elim.2)
-/
#guard_msgs in
initialize_simps_projections Foo2


@[simps]
def Foo2.foo2 : Foo2 Nat := ⟨(0, 0)⟩

Expand Down

0 comments on commit 14c4fac

Please sign in to comment.