What version of Go are you using (go version)?
$ gotip version
`devel go1.18-a83a558 Mon Sep 20 00:13:47 2021 +0000`
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
linux amd64
What did you do?
I wrote a generic function(inside package), run gotip doc -all -c -u [package-name]
What did you expect to see?
expect to see the function signature in output, like func Intersection[T comparable](slices... []T) []T
What did you see instead?
functions that return []T are not printed, others like func Some[T any](slice []T, pred func(T) bool) bool are printed
I tried dig into the doc generator, found that
- these functions are now considered to be
factory functions of T, their associations go typ.funcs.set branch instead of r.funcs.set
cleanupTypes() deleted T from r.types because it has no definition
- then T is not included in
docPkg.Types, thus no results are printed
with following immature hack diff those functions will be printed:
@@ -429,8 +436,9 @@ func (r *reader) readFunc(fun *ast.FuncDecl) {
}
// If there is exactly one result type,
// associate the function with that type.
- if numResultTypes == 1 {
+ if numResultTypes == 1 && typ.decl != nil {
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env)?linux amd64
What did you do?
I wrote a generic function(inside package), run
gotip doc -all -c -u [package-name]What did you expect to see?
expect to see the function signature in output, like
func Intersection[T comparable](slices... []T) []TWhat did you see instead?
functions that return
[]Tare not printed, others likefunc Some[T any](slice []T, pred func(T) bool) boolare printedI tried dig into the doc generator, found that
factory functions of T, their associations gotyp.funcs.setbranch instead ofr.funcs.setcleanupTypes()deleted T from r.types because it has no definitiondocPkg.Types, thus no results are printedwith following
immature hackdiff those functions will be printed: