Skip to content

go/doc: cannot associate examples with generic methods #52496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jba opened this issue Apr 22, 2022 · 2 comments
Closed

go/doc: cannot associate examples with generic methods #52496

jba opened this issue Apr 22, 2022 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.

Comments

@jba
Copy link
Contributor

jba commented Apr 22, 2022

When associating examples with types, functions and methods (go/doc/example.go:classifyExamples), the identifier name associated with method M of type G[T] is G[T]_M. Since square brackets are not allowed in Go identifiers, it isn't possible to write an example function that matches that string.

I suggest removing the square brackets, as was done in https://golang.org/cl/354689 to fix #48032.

@jba jba added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 22, 2022
@jba jba self-assigned this Apr 22, 2022
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/401761 mentions this issue: go/doc: remove brackets from receiver in example identifier

@jba
Copy link
Contributor Author

jba commented Apr 22, 2022

Clarification: removing the square brackets and everything in between them. So G[T]_M becomes G_M.

@rsc rsc unassigned jba Jun 22, 2022
@golang golang locked and limited conversation to collaborators Jun 22, 2023
mateusz834 pushed a commit to mateusz834/tgoast that referenced this issue Dec 31, 2024
When constructing a string for a method that will match an example
function's name, remove brackets from the receiver. This makes it
possible to write an example associated with a method of a generic
type.

Also, modify the test for classifying examples to check that all the
expected examples actually appear.

Fixes golang/go#52496.

Change-Id: Iebc5768f6cb91df9671dd701b97958fb8081f986
Reviewed-on: https://go-review.googlesource.com/c/go/+/401761
TryBot-Result: Gopher Robot <[email protected]>
Run-TryBot: Jonathan Amsterdam <[email protected]>
Reviewed-by: Robert Findley <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants