Skip to content
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

cmd/compile: IncompatibleAssign spreading slice of interface compliant types into variadic function accepting interface #62151

Closed
dillonstreator opened this issue Aug 19, 2023 · 1 comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@dillonstreator
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.21.0 windows/amd64

While this doesn't seem to be version-specific and appears to be an intentional design choice, it is unexpected behavior.

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\dillon\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\dillon\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.21.0
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0

What did you do?

Spreading a slice of interface compliant types into a function expecting variadic interface parameter results in an unexpected IncompatibleAssign. Directly passing the interface compliant types to the function as comma separated arguments compiles fine.

https://go.dev/play/p/NP6-6rHauMC

What did you expect to see?

No compilation error

What did you see instead?

Compilation error

cannot use things (variable of type []thing) as []doer value in argument to doit
@dmitshur dmitshur changed the title compiler: IncompatibleAssign spreading slice of interface compliant types into variadic function accepting interface cmd/compile: IncompatibleAssign spreading slice of interface compliant types into variadic function accepting interface Aug 19, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Aug 19, 2023
@dmitshur dmitshur added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. compiler/runtime Issues related to the Go compiler and/or runtime. and removed compiler/runtime Issues related to the Go compiler and/or runtime. labels Aug 19, 2023
@dmitshur dmitshur added this to the Backlog milestone Aug 19, 2023
@dmitshur
Copy link
Contributor

dmitshur commented Aug 19, 2023

What does the Go language specification say about this?

I expect this is working as intended, and the https://go.dev/doc/faq#convert_slice_with_same_underlying_type entry covers this situation.

Also see #38385 (comment) and #38753. I'll close it as a duplicate of that, but please comment if I missed something. (CC @ianlancetaylor.)

@dmitshur dmitshur closed this as not planned Won't fix, can't repro, duplicate, stale Aug 19, 2023
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. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants