-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.TypeInferenceIssue is related to generic type inferenceIssue is related to generic type inferencecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
Go version
go 1.24.0
Output of go env in your module/workspace:
set AR=ar
set CC=gcc
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_ENABLED=0
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set CXX=g++
set GCCGO=gccgo
set GO111MODULE=on
set GOAMD64=v1
set GOARCH=amd64
set GOAUTH=netrc
set GOBIN=
set GOCACHE=C:\Users\lee\AppData\Local\go-build
set GOCACHEPROG=
set GODEBUG=
set GOENV=C:\Users\lee\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFIPS140=off
set GOFLAGS=
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\lee\AppData\Local\Temp\go-build1694421810=/tmp/go-build -gno-record-gcc-switches
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMOD=D:\Dev\go_demo\go.mod
set GOMODCACHE=C:\Users\lee\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\lee\go
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=D:/Go
set GOSUMDB=sum.golang.org
set GOTELEMETRY=local
set GOTELEMETRYDIR=C:\Users\lee\AppData\Roaming\go\telemetry
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=D:\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.24.0
set GOWORK=
set PKG_CONFIG=pkg-configWhat did you do?
type Set[E comparable] map[E]struct{}
func NewSet[E comparable](cap int) Set[E] {
return make(map[E]struct{}, cap)
}
func (s Set[E]) AppendSelf(element E) Set[E] {
s[element] = struct{}{}
return s
}
type FromIterator[E, ES any] interface {
AppendSelf(E) ES
}
func Map[T, R any, RS FromIterator[R, RS]](ts []T, fn func(T) R, toFn func(int) RS) RS {
rs := toFn(len(ts))
for _, t := range ts {
rs = rs.AppendSelf(fn(t))
}
return rs
}
func main() {
arr := []int{1, 2, 3, 4, 5, 6}
//compile:
//1.23.6 ok
//1.24.0 err
set := Map(arr, func(t int) int {
return t + 1
}, NewSet)
fmt.Println(set)
}
What did you see happen?
compile ok
What did you expect to see?
compile ok
Metadata
Metadata
Assignees
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.TypeInferenceIssue is related to generic type inferenceIssue is related to generic type inferencecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Type
Projects
Status
Todo