-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Open
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Description
Go version
go version go1.24.0 linux/arm64, go version go1.25.1 linux/arm64
Output of go env
in your module/workspace:
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/redacted/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/redacted/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build962130345=/tmp/go-build -gno-rec
ord-gcc-switches'
GOHOSTARCH='arm64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/redacted/debug-go/go.mod'
GOMODCACHE='/home/redacted/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/redacted/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/redacted/sdk/go1.25.1'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/redacted/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/redacted/sdk/go1.25.1/pkg/tool/linux_arm64'
GOVCS=''
GOVERSION='go1.25.1'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
Hi,
I was playing with type aliasing and I stubbled accros the following issue:
test/test.go
package test
type A[T any] interface {
Alias() Alias[T]
}
type Alias[T any] = A[T]
main.go
package main
import "debug-go/test"
type C test.A[int]
func main() {}
go.mod
module debug-go
go 1.25.1
What did you see happen?
$ go build ./...
# debug-go
fatal error: all goroutines are asleep - deadlock!
goroutine 1 [sync.Mutex.Lock]:
internal/sync.runtime_SemacquireMutex(0x400008f7f8?, 0x4?, 0x400017ccf0?)
runtime/sema.go:95 +0x28
internal/sync.(*Mutex).lockSlow(0x40000e97c8)
internal/sync/mutex.go:149 +0x170
internal/sync.(*Mutex).Lock(...)
internal/sync/mutex.go:70
sync.(*Mutex).Lock(...)
sync/mutex.go:46
cmd/compile/internal/types2.(*Named).resolve(0x40000e97a0)
cmd/compile/internal/types2/named.go:176 +0x94
cmd/compile/internal/types2.(*Named).TypeParams(...)
cmd/compile/internal/types2/named.go:322
cmd/compile/internal/types2.(*subster).typ(0x400008fbf0, {0xb66508, 0x40000e9810})
cmd/compile/internal/types2/subst.go:245 +0x3d8
cmd/compile/internal/types2.(*Checker).subst(0x0, {0x0?, 0x8fce8?, 0x40?}, {0xb66508, 0x40000e9810}, 0x400017cd50, 0x0, 0x40000a73a0)
cmd/compile/internal/types2/subst.go:78 +0x168
cmd/compile/internal/types2.(*Checker).newAliasInstance(0x0, {0x0?, 0x0?, 0x0?}, 0x40003d2a80, {0x40000bd360, 0x1, 0x1}, 0x0, 0x40000a73a0)
cmd/compile/internal/types2/alias.go:165 +0x168
cmd/compile/internal/types2.(*Checker).instance(0x0, {0x0, 0x0, 0x0}, {0xb67c90, 0x40003d2a80}, {0x40000bd360, 0x1, 0x1}, 0x0, ...)
cmd/compile/internal/types2/instantiate.go:150 +0x5b8
cmd/compile/internal/types2.Instantiate(0x40000a73a0, {0xb66530, 0x40003d2a80}, {0x40000bd360, 0x1, 0x1}, 0x0)
cmd/compile/internal/types2/instantiate.go:70 +0x25c
cmd/compile/internal/importer.(*reader).doTyp(0x4000090098)
cmd/compile/internal/importer/ureader.go:258 +0xb8
cmd/compile/internal/importer.(*pkgReader).typIdx(...)
cmd/compile/internal/importer/ureader.go:231
cmd/compile/internal/importer.(*reader).typ(0x40000904a8)
cmd/compile/internal/importer/ureader.go:201 +0x138
cmd/compile/internal/importer.(*reader).param(0x40000904a8)
cmd/compile/internal/importer/ureader.go:365 +0x60
cmd/compile/internal/importer.(*reader).params(0x40000904a8)
cmd/compile/internal/importer/ureader.go:355 +0x78
cmd/compile/internal/importer.(*reader).signature(0x40000904a8, 0x0, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0})
cmd/compile/internal/importer/ureader.go:345 +0x5c
cmd/compile/internal/importer.(*reader).interfaceType(0x40000904a8)
cmd/compile/internal/importer/ureader.go:326 +0x138
cmd/compile/internal/importer.(*reader).doTyp(0x40000904a8)
cmd/compile/internal/importer/ureader.go:283 +0x358
cmd/compile/internal/importer.(*pkgReader).typIdx(...)
cmd/compile/internal/importer/ureader.go:231
cmd/compile/internal/importer.(*reader).typ(0x40003d6420)
cmd/compile/internal/importer/ureader.go:201 +0x138
cmd/compile/internal/importer.ReadPackage.(*pkgReader).objIdx.func1.1(0x1?)
cmd/compile/internal/importer/ureader.go:450 +0x38
cmd/compile/internal/types2.(*Named).resolve(0x40000e97a0)
cmd/compile/internal/types2/named.go:215 +0x12c
cmd/compile/internal/types2.(*Named).TypeParams(...)
cmd/compile/internal/types2/named.go:322
cmd/compile/internal/types2.isGeneric({0xb66508?, 0x40000e97a0?})
cmd/compile/internal/types2/predicates.go:146 +0x8c
cmd/compile/internal/types2.(*Checker).genericType(0x40001621e0, {0xb6a5b8, 0x40003d1bd0}, 0x40000907b8)
cmd/compile/internal/types2/typexpr.go:215 +0x9c
cmd/compile/internal/types2.(*Checker).instantiatedType(0x40001621e0, {0xb6a5b8, 0x40003d1bd0}, {0x40000bd330, 0x1, 0x1}, 0x12?)
cmd/compile/internal/types2/typexpr.go:451 +0x160
cmd/compile/internal/types2.(*Checker).typInternal(0x40001621e0, {0xb6a570, 0x40003d6000}, 0x40003d6360)
cmd/compile/internal/types2/typexpr.go:294 +0x748
cmd/compile/internal/types2.(*Checker).definedType(0x40001621e0, {0xb6a570, 0x40003d6000}, 0x18d9c?)
cmd/compile/internal/types2/typexpr.go:195 +0x28
cmd/compile/internal/types2.(*Checker).typeDecl(0x40001621e0, 0x40003d6360, 0x40003cbf20, 0x0)
cmd/compile/internal/types2/decl.go:564 +0x3fc
cmd/compile/internal/types2.(*Checker).objDecl(0x40001621e0, {0xb6f2e0, 0x40003d6360}, 0x0)
cmd/compile/internal/types2/decl.go:200 +0x768
cmd/compile/internal/types2.(*Checker).packageObjects(0x40001621e0)
cmd/compile/internal/types2/resolver.go:681 +0x3d8
cmd/compile/internal/types2.(*Checker).checkFiles(0x40001621e0, {0x40000912b8?, 0x30?, 0x11c36e0?})
cmd/compile/internal/types2/check.go:497 +0x278
cmd/compile/internal/types2.(*Checker).Files(0xffffcc2a8f5f?, {0x40000912b8?, 0x0?, 0x0?})
cmd/compile/internal/types2/check.go:460 +0x80
cmd/compile/internal/types2.(*Config).Check(0x40000e9420, {0xffffcc2a8f5f?, 0x400000e0a7?}, {0x40000912b8, 0x1, 0x1}, 0x40003d60c0)
cmd/compile/internal/types2/api.go:488 +0x14c
cmd/compile/internal/noder.checkFiles({0x0, {0x0, 0x0}}, {0x40000a4680, 0x1, 0x1f5610?})
cmd/compile/internal/noder/irgen.go:95 +0x490
cmd/compile/internal/noder.writePkgStub({0x0?, {0x0?, 0x0?}}, {0x40000a4680, 0x1, 0x1})
cmd/compile/internal/noder/unified.go:319 +0x48
cmd/compile/internal/noder.unified({0x0?, {0x0?, 0x0?}}, {0x40000a4680?, 0x8fc360?, 0x40003beb40?})
cmd/compile/internal/noder/unified.go:195 +0xac
cmd/compile/internal/noder.LoadPackage({0x40000c6120, 0x1, 0x2})
cmd/compile/internal/noder/noder.go:77 +0x36c
cmd/compile/internal/gc.Main(0xa17728)
cmd/compile/internal/gc/main.go:208 +0xb54
main.main()
cmd/compile/main.go:57 +0xfc
What did you expect to see?
When having all the type definition in the same file, there is not issue compiling:
package main
type A[T any] interface {
Alias() Alias[T]
}
type Alias[T any] = A[T]
type C A[int]
func main() {}
I suspect I would assume the compilation to succeed as if I had written A[T]
instead of Alias[T]
in the type definition.
Metadata
Metadata
Assignees
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.