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

github.com/bobg/go-generics/v2/slices: type inference bug? #61991

Closed
bobg opened this issue Aug 13, 2023 · 2 comments
Closed

github.com/bobg/go-generics/v2/slices: type inference bug? #61991

bobg opened this issue Aug 13, 2023 · 2 comments

Comments

@bobg
Copy link

bobg commented Aug 13, 2023

Getting this error:

type func(a E, b E) bool of less does not match inferred type func(a E, b E) int for func(a E, b E) int

...for code that explicitly declares less as func(a, b E) bool and uses it in a func(a, b E) bool context. Not an int in sight. Details follow.

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

$ go version
go version go1.21.0 linux/amd64

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
GO111MODULE='on'
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/bobg/.cache/go-build'
GOENV='/home/bobg/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/bobg/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/bobg/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/bobg/go/src/github.com/bobg/go-generics/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-build2985862645=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Checked out the latest version of decouple and ran go vet on it:

$ git clone https://github.com/bobg/decouple.git
$ cd decouple
$ go vet ./...

What did you expect to see?

No output.

What did you see instead?

../../../../pkg/mod/github.com/bobg/go-generics/v2@v2.2.1/slices/dropin.go:150:21: type func(a E, b E) bool of less does not match inferred type func(a E, b E) int for func(a E, b E) int
../../../../pkg/mod/github.com/bobg/go-generics/v2@v2.2.1/slices/dropin.go:156:27: type func(a E, b E) bool of less does not match inferred type func(a E, b E) int for func(a E, b E) int
../../../../pkg/mod/github.com/bobg/go-generics/v2@v2.2.1/slices/dropin.go:167:32: type func(a E, b E) bool of less does not match inferred type func(a E, b E) int for func(a E, b E) int

This refers to these lines in my go-generics module: 150, 156, 167.

These lines are meant to make my slices package be a drop-in replacement for the new Go 1.21 slices package. In each case, my less is declared to be func(a, b E) bool (with E a type parameter), and is passed to a corresponding function in Go's slices, also expecting a func(a, b E) bool. Not an int in sight.

Reproducible after go clean -modcache.

@seankhliao
Copy link
Member

Duplicate of #61374

@seankhliao seankhliao marked this as a duplicate of #61374 Aug 13, 2023
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Aug 13, 2023
@blackgreen100
Copy link

@seankhliao the issue you linked gives 404, please can you update it?

@golang golang locked and limited conversation to collaborators Oct 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants