-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Closed as not planned
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.2 darwin/arm64
Output of go env in your module/workspace:
AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/s-ved/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/s-ved/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/25/n9yj6g1n2wqbvrk2__2sv8840000gr/T/go-build1621757110=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/s-ved/repos/tests/go_just_main/go.mod'
GOMODCACHE='/Users/s-ved/go/pkg/mod'
GOOS='darwin'
GOPATH='/Users/s-ved/go'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/s-ved/homebrew/Cellar/go/1.24.2/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/s-ved/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/s-ved/homebrew/Cellar/go/1.24.2/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24.2'
GOWORK=''
PKG_CONFIG='pkg-config'What did you do?
type Printable interface {
Print()
}
type Printers struct {
printers []*PrinterWithInk[Printable]
}
type PrinterWithInk[T Printable] struct {
printer T
ink uint
}
func NewPrinterWithInk[T Printable](printer T, ink uint) *PrinterWithInk[T] {
return &PrinterWithInk[T]{printer: printer, ink: ink}
}
func NewPrinterWithInkTracked[T Printable](ps Printers, printer T, ink uint) *PrinterWithInk[T] {
p := NewPrinterWithInk[T](printer, ink)
ps.printers = append(ps.printers, p)
return p
}What did you see happen?
Error at line ps.printers = append(ps.printers, p):
- cannot use p (variable of type *PrinterWithInk[T]) as *PrinterWithInk[Printable] value in argument to append [IncompatibleAssign]
What did you expect to see?
No error, T is constrained to be Printable in the function declaration.
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.