Skip to content

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

@dillonstreator

Description

@dillonstreator

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions