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

range over func: it is NOT yet permitted to omit unwanted variables #67075

Closed
gaissmai opened this issue Apr 26, 2024 · 1 comment
Closed

range over func: it is NOT yet permitted to omit unwanted variables #67075

gaissmai opened this issue Apr 26, 2024 · 1 comment

Comments

@gaissmai
Copy link

Go version

gotip

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/gaissmai/.cache/go-build'
GOENV='/home/gaissmai/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/gaissmai/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/gaissmai/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/gaissmai/sdk/gotip'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/gaissmai/sdk/gotip/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.23-b384ee7ce Fri Apr 26 18:12:56 2024 +0000'
GODEBUG=''
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/gaissmai/project/rangefunc/go.mod'
GOWORK=''
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-build4171176773=/tmp/go-build -gno-record-gcc-switches'

What did you do?

playing with range over funcs, got the following error:
range over all (value of type func(yield func(a int, b int) bool)) must have two iteration variables
please see the code in the playground: https://go.dev/play/p/HHJaatn3WAl?v=gotip

What did you see happen?

got the compiler error:
./prog.go:14:17: range over all (value of type func(yield func(a int, b int) bool)) must have two iteration variables

What did you expect to see?

no compiler error, the spec says it is allowed to omit unwanted variables:

for x, y := range f { ... }
for x, _ := range f { ... }
for _, y := range f { ... }
for x := range f { ... }
for range f { ... }
@seankhliao
Copy link
Member

Duplicate of #65236

@seankhliao seankhliao marked this as a duplicate of #65236 Apr 26, 2024
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants