Closed as not planned
Description
What version of Go are you using (go version
)?
$ go version go version go1.19.12 darwin/arm64
Does this issue reproduce with the latest release?
No, only reproducible with version before 1.20.
I checked that it's reproducible with docker images golang:1.18.10-alpine, 1.19.0-alpine, and 1.19.12-alpine.
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="on" GOARCH="arm64" GOBIN="" GOCACHE="/Users/jiho.park/Library/Caches/go-build" GOENV="/Users/jiho.park/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="arm64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/jiho.park/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/jiho.park/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/Users/jiho.park/sdk/go1.19.12" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/Users/jiho.park/sdk/go1.19.12/pkg/tool/darwin_arm64" GOVCS="" GOVERSION="go1.19.12" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/dev/null" 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 arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/m2/xcs64bj145x1v3vcr4kzbb_whbnl4r/T/go-build4205325580=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
func main() {
fmt.Println(reflect.TypeOf(i1()).Kind())
fmt.Println(reflect.TypeOf(i2()).Kind())
fmt.Println(reflect.TypeOf(i3()).Kind())
fmt.Println(reflect.TypeOf(i1()) == reflect.TypeOf(i3()))
}
func i1() any {
type t[T any] string
return t[int]("")
}
func i2() any {
type t[T any] int
return t[int](0)
}
func i3() any {
type t[T any] struct{}
return t[int]{}
}
The function-scoped types should be a generic type with the same name, and initiated with the same type parameters.
What did you expect to see?
string
int
struct
false
0 {}
What did you see instead?
struct
struct
struct
true
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x104358798]
goroutine 1 [running]:
fmt.(*buffer).writeString(...)
/Users/jiho.park/sdk/go1.19.12/src/fmt/print.go:82
fmt.(*fmt).padString(0x104386fda?, {0x0, 0xa})
/Users/jiho.park/sdk/go1.19.12/src/fmt/format.go:110 +0x224
fmt.(*fmt).fmtS(0x10b7f5701?, {0x0?, 0x14000098cd8?})
/Users/jiho.park/sdk/go1.19.12/src/fmt/format.go:359 +0x40
fmt.(*pp).fmtString(0x10b7f5800?, {0x0?, 0x10bb2bfc8?}, 0x430f2ec?)
/Users/jiho.park/sdk/go1.19.12/src/fmt/print.go:474 +0x98
fmt.(*pp).printValue(0x1400009e410, {0x1043af6a0?, 0x1043a7180?, 0xd0?}, 0x76, 0x0)
/Users/jiho.park/sdk/go1.19.12/src/fmt/print.go:788 +0xf70
fmt.(*pp).printArg(0x1400009e410, {0x1043af6a0?, 0x1043a7180}, 0x76)
/Users/jiho.park/sdk/go1.19.12/src/fmt/print.go:743 +0x788
fmt.(*pp).doPrintln(0x1400009e410, {0x14000098f38?, 0x3, 0x104386700?})
/Users/jiho.park/sdk/go1.19.12/src/fmt/print.go:1200 +0x178
fmt.Fprintln({0x1043c0d58, 0x140000a0008}, {0x14000098f38, 0x3, 0x3})
/Users/jiho.park/sdk/go1.19.12/src/fmt/print.go:284 +0x44
fmt.Println(...)
/Users/jiho.park/sdk/go1.19.12/src/fmt/print.go:294
main.main()
/Users/jiho.park/repos/test/asdf/main.go:29 +0x29c