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

Closed

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

Activity

  1. gopherbot commented on Nov 1, 2024

    @gopherbot
    Contributor

    Change https://go.dev/cl/624335 mentions this issue: cmd/compile: print the variadic argument in variadic form in compiler error message

  2. fengyoulin commented on Nov 1, 2024

    @fengyoulin
    Member

    Change https://go.dev/cl/624335 mentions this issue: cmd/compile: print the variadic argument in variadic form in compiler error message

    I have a fix, PTAL.

  3. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Nov 1, 2024
  4. added this to the Go1.24 milestone on Nov 1, 2024
  5. added a commit that references this issue on Nov 4, 2024
    76f3e0a
  6. locked and limited conversation to collaborators on Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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