-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
What version of Go are you using (go version)?
$ go version go version go1.18beta1 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go envGO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/olenasynenka/Library/Caches/go-build"
GOENV="/Users/olenasynenka/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/olenasynenka/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/olenasynenka/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/olenasynenka/sdk/go1.18beta1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/olenasynenka/sdk/go1.18beta1/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18beta1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/olenasynenka/go/src/generics/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/f8/xmg0swjx04jfwc7zln05fxlh0000gn/T/go-build495723722=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
I created a generic function F with type parameter "T" and a separate struct called “T”.
Then I run cmd/godoc to view it’s documentation.
Steps to reproduce:
mkdir /tmp/test
cd /tmp/test
go mod init test
echo 'package test; func F[T any](t T) {}; type T struct{}' > test.go
go install golang.org/x/tools/cmd/godoc@latest
godoc
# In browser navigate to localhost:6060/pkg/test
What did you expect to see?
Documentation of generic func F with type param “T” used in parameter list. Type “T” doesn’t link anywhere.
What did you see instead?
Type parameter “T” is rendered with a hyper-link that links to incorrect type (struct "T").
This should not happen as struct “T” and type parameter “T” are different entities.
