Closed
Description
Go version
go version go1.23.3 linux/amd64 & gopls version golang.org/x/tools/gopls v0.17.0-pre.3
Output of go env
in your module/workspace:
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/ren/.cache/go-build'
GOENV='/home/ren/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/ren/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/ren/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.23.3'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/ren/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/ren/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-build3925782217=/tmp/go-build -gno-record-gcc-switches'
What did you do?
package main
import "iter"
func D() iter.Seq[uint8] {
return func(yield func(uint8) bool) {
ok := yield(0x01)
ok = ok && yield(0x01)
ok = ok && yield(0x01)
ok = ok && yield(0x01)
}
}
What did you see happen?
Get 3 warnings that yield maybe called again.
What did you expect to see?
No warnings.
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
gabyhelp commentedon Nov 27, 2024
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
adonovan commentedon Nov 27, 2024
Smaller repro:
The first call to yield is unconditional, and the second depends on the result of the first, so there's no problem there. But the third depends on the phi(false, t1) node representing the two alternatives of
ok && yield(1)
:The analyzer should work harder to recursively analyze phi nodes used as conditions, especially when the phi operands are constants.
gopherbot commentedon Nov 27, 2024
Change https://go.dev/cl/632117 mentions this issue:
gopls/internal/analysis/yield: peephole-optimize phi(false, x)
gopls/internal/analysis/yield: peephole-optimize phi(false, x)
gopherbot commentedon Dec 3, 2024
Change https://go.dev/cl/633196 mentions this issue:
gopls/internal/analysis/yield: add comment about dataflow
gopls/internal/analysis/yield: add comment about dataflow
gopls/internal/analysis/yield: add comment about dataflow
gopherbot commentedon Dec 4, 2024
Change https://go.dev/cl/633709 mentions this issue:
gopls/internal/analysis/yield: add comment about dataflow
gopherbot commentedon Dec 4, 2024
Change https://go.dev/cl/633702 mentions this issue:
gopls/internal/analysis/yield: peephole-optimize phi(false, x)