Skip to content

Commit 5edebcb

Browse files
committed
fix(Tactic/ToFun): correct location of hovers
When an explicit name for the new declaration is given, ensure to make hovering over the to_fun keyword show the keyword's documentation, and hovering over the new declaration show the declaration's name. Right now, it is the opposite way around.
1 parent dd364d5 commit 5edebcb

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Mathlib/Tactic/ToFun.lean

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ def toFunImpl (src : Name) (stx : Syntax) (kind : AttributeKind) : AttrM Name :=
4949
let name := match id with
5050
| some name => (src.splitAt name.getId.getNumParts).1 ++ name.getId
5151
| none => src.appendBefore "fun_"
52+
let mut loc := tk
5253
if let some id := id then
54+
loc := id
5355
if name == src.appendBefore "fun_" then
5456
logWarningAt id m!"`to_fun` correctly autogenerated the provided name `{.ofConstName name}`.\
5557
\nYou may remove it."
56-
MetaM.run' <| addRelatedDecl src name tk optAttr
58+
MetaM.run' <| addRelatedDecl src name loc optAttr
5759
(docstringPrefix? := s!"Eta-expanded form of `{src}`") (hoverInfo := true)
5860
fun value levels => do
5961
let type ← inferType value

0 commit comments

Comments
 (0)