Skip to content

reflect: artifact in Type.String() for nested generic local type #67395

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
d-enk opened this issue May 15, 2024 · 1 comment
Closed

reflect: artifact in Type.String() for nested generic local type #67395

d-enk opened this issue May 15, 2024 · 1 comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.

Comments

@d-enk
Copy link

d-enk commented May 15, 2024

Go version

go version go1.22.3 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GONOPROXY='*.r-99.com'
GONOSUMDB='*.r-99.com'
GOOS='linux'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/linuxbrew/.linuxbrew/Cellar/go/1.22.3/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/linuxbrew/.linuxbrew/Cellar/go/1.22.3/libexec/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.3'
GCCGO='/usr/bin/gccgo'
GOAMD64='v1'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1045386246=/tmp/go-build -gno-record-gcc-switches

What did you do?

package main

import "reflect"

func main() {
	type Type[T any] struct{ t T }

	println(
		reflect.TypeOf(Type[Type[int]]{}).String(),
	)
	// main.Type[main.Type[int]·1]
}

playground

Reproduced since 1.20 (no 18/19)

What did you see happen?

unexpected ·1

What did you expect to see?

no artifact

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label May 15, 2024
@ianlancetaylor
Copy link
Member

This is not a bug. It's possible to have identically named types, and we need some way to distinguish them. Consider

https://go.dev/play/p/B-LoKA1n2LE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Projects
Development

No branches or pull requests

3 participants