Skip to content

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

Description

@rothelius

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.

Activity

  1. 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 [/+] on Jan 5, 2025
  2. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Jan 5, 2025
  3. randall77 commented on Jan 7, 2025

    @randall77
    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

  4. self-assigned this
    on Jan 7, 2025
  5. added this to the Go1.24 milestone on Jan 7, 2025
  6. griesemer commented on Jan 7, 2025

    @griesemer
    Contributor

    @randall77 Agreed. I will take care of this.

  7. gopherbot commented on Jan 7, 2025

    @gopherbot
    Contributor

    Change https://go.dev/cl/640599 mentions this issue: go/types, types2: require iterator yield to return bool (work-around)

  8. locked and limited conversation to collaborators on Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions