Skip to content

cmd/compile, go/types: the "have" section with variadic argument show slice and not variadic in "not-enough/too-many values" compiler error message #70150

@odeke-em

Description

@odeke-em

Go version

go version devel go1.24-851ebc2dca Tue Oct 29 08:17:00 2024 +0000 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOAUTH='netrc'
GOBIN='/home/emmanuel/go/src/go.googlesource.com/go/bin'
GOCACHE='/home/emmanuel/.cache/go-build'
GOENV='/home/emmanuel/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/emmanuel/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/emmanuel/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/emmanuel/go/src/go.googlesource.com/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/emmanuel/go/src/go.googlesource.com/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.24-851ebc2dca Tue Oct 29 08:17:00 2024 +0000'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/emmanuel/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/emmanuel/go/src/github.com/googleapis/google-cloud-go/spanner/go.mod'
GOWORK='/home/emmanuel/go/src/github.com/googleapis/google-cloud-go/go.work'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2861148706=/tmp/go-build -gno-record-gcc-switches'

What did you do?

https://go.dev/play/p/OwK-zDVUefq

package main

import "context"

func main() {
	values := []int{10, 12, 20}
	vari(context.Background(), values...)
	vari(context.Background(), "ab", "cd", values...)
}

func vari(ctx context.Context, method string, values ...int) {
	_ = values
}

What did you see happen?

./prog.go:7:29: not enough arguments in call to vari
	have (context.Context, []int)
	want (context.Context, string, ...int)
./prog.go:8:41: too many arguments in call to vari
	have (context.Context, string, string, []int)
	want (context.Context, string, ...int)

What did you expect to see?

./prog.go:7:29: not enough arguments in call to vari
	have (context.Context, ...int)
	want (context.Context, string, ...int)
./prog.go:8:41: too many arguments in call to vari
	have (context.Context, string, string, ...int)
	want (context.Context, string, ...int)

Kindly cc-ing @griesemer @findleyr

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

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions