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

cmd/compile: range over func internal compiler error with named bool type in yield #71131

Open
fabe-xx opened this issue Jan 5, 2025 · 3 comments
Assignees
Labels
Bug Issues describing a bug in the Go implementation. compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@fabe-xx
Copy link

fabe-xx commented Jan 5, 2025

Go version

go version go1.23.4 darwin/amd64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/fabianr/Library/Caches/go-build'
GOENV='/Users/fabianr/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT='aliastypeparams'
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/fabianr/e/be/gamelogic/gohome/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/fabianr/e/be/gamelogic/gohome'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.23.4'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/fabianr/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/dev/null'
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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/5y/2cd0ydxn7nl7sz2nnk3d91xc0000gn/T/go-build3384530003=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Ran this playground code.

What did you see happen?

./prog.go:7:2: internal compiler error: func() (#r bool) is not assignable to func() main.Bool

What did you expect to see?

Either no error, or an error that isn't an internal compiler error.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jan 5, 2025
@seankhliao seankhliao changed the title cmd/compile: Internal compiler error when ranging over a func with a named bool return cmd/compile: range over func internal compiler error with named bool type in yield Jan 5, 2025
@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 5, 2025
@gabyhelp gabyhelp added the Bug Issues describing a bug in the Go implementation. label Jan 7, 2025
@randall77
Copy link
Contributor

Unified IR is having trouble with this code, because there's an argument/formal mismatch it doesn't think typechecks.

Something like:

type Bool bool
var iter func(func() Bool) = ... // user's iter function
var yield1 func() bool = ... // the loop body closure
iter(yield1)

I think the frontend should either declare the yield function with a return type that matches the user's iteration function's arg's return type, or disallow named booleans as the return type.
I would lean towards the latter, as the spec only lists bool, not a named bool, as the return type.

@griesemer

@griesemer griesemer self-assigned this Jan 7, 2025
@griesemer griesemer added this to the Go1.24 milestone Jan 7, 2025
@griesemer
Copy link
Contributor

@randall77 Agreed. I will take care of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues describing a bug in the Go implementation. compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

6 participants