Skip to content

cmd/compile: internal compiler error: assertion failed #66132

@karelbilek

Description

@karelbilek

Go version

go version go1.22.0 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/karelbilek/Library/Caches/go-build'
GOENV='/Users/karelbilek/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/karelbilek/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/karelbilek/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/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/karelbilek/pstopdfa-gs-wazero/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 -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/qk/9bbz1shn0dj8vdkg4lf76clh0000gn/T/go-build3538269826=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Small repro:

package main

func main() {
}

func SomeFunc() (map[string]int, error) {
	panic("foo")

	arr := []string{}

	mapp := map[string]int{}

LABEL:
	for _, f := range arr {
		continue LABEL
		mapp[f] = 2
	}

	return mapp, nil
}

Replicable here.

https://go.dev/play/p/fLjUPRVQ90v

Note that all is needed:

  1. the panic("foo")
  2. the labeled for loop (removing the label removes the issue)
  3. the mapp variable

What did you see happen?

CLOSURE [prog.go:14:20:var arr []string ./prog.go:16:3:var mapp map[string]int]
<unknown line number>: internal compiler error: assertion failed

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new

See playground.

What did you expect to see?

This should build sucessfully.

The code itself is dumb and is just the smallest repro I can do.

go1.21 works on the same codebase (go vet warns, but that's expected).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions