File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,9 +47,10 @@ def toFunImpl (src : Name) (stx : Syntax) (kind : AttributeKind) : AttrM Name :=
4747 if (kind != AttributeKind.global) then
4848 throwError "`to_fun` can only be used as a global attribute"
4949 let name := match id with
50- | some name =>
51- (src.splitAt name.getId.getNumParts).1 ++ name.getId
50+ | some name => (src.splitAt name.getId.getNumParts).1 ++ name.getId
5251 | none => src.appendBefore "fun_"
52+ if id.isSome && name == src.appendBefore "fun_" then
53+ logWarningAt tk "the autogenerated name `name` matches the one provided"
5354 MetaM.run' <| addRelatedDecl src name tk optAttr
5455 (docstringPrefix? := s! "Eta-expanded form of `{ src} `" ) (hoverInfo := true )
5556 fun value levels => do
Original file line number Diff line number Diff line change 1+
2+
13import Mathlib.Tactic.ToFun
24import Mathlib.Analysis.Normed.Ring.Basic
35
46set_option pp.unicode.fun true
57
6- variable {R : Type *}
8+ /-- warning: the autogenerated name `name` matches the one provided -/
9+ #guard_msgs in
10+ @ [to_fun fun_id_eq']
11+ lemma id_eq' {R : Type *} : (@id R) = id := id_eq _
712
813@ [to_fun baz]
914lemma Foo.bar (f g : ℝ → ℝ) : f * g = g * f := mul_comm f g
15+
1016/-- info: Foo.baz (f g : ℝ → ℝ) : (fun i ↦ f i * g i) = fun i ↦ g i * f i -/
1117#guard_msgs in #check Foo.baz
1218
@@ -52,6 +58,11 @@ theorem Function.mul_comm (f g : ℝ → ℝ) : f * g = g * f := _root_.mul_comm
5258#guard_msgs in
5359#check Function.fun_mul_comm
5460
61+ /-- warning: the autogenerated name `name` matches the one provided -/
62+ #guard_msgs in
63+ @ [to_fun fun_bar]
64+ theorem bar (f g : ℝ → ℝ) : f * g = g * f := _root_.mul_comm f g
65+
5566/-- Look I am the doc-string of `foo`. -/
5667@[to_fun]
5768theorem foo : (1 : Nat → Nat) = 1 := rfl
You can’t perform that action at this time.
0 commit comments