Skip to content

cmd/compile: internal compiler error: panic: interface conversion: ir.Node is *ir.IndexExpr, not *ir.StarExpr #77832

@BrownNPC

Description

@BrownNPC

Go version

go version go1.26.0 linux/amd64

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN='/home/linus/.local/share/mise/installs/go/1.26.0/bin'
GOCACHE='/home/linus/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/linus/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build624602782=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/linus/coding/compilerError/go.mod'
GOMODCACHE='/home/linus/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/linus/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/linus/.local/share/mise/installs/go/1.26.0'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/linus/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/linus/.local/share/mise/installs/go/1.26.0/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.26.0'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

I was just writing benchmarks and tests for my new library when I discovered a compiler error.

Here's how to reproduce it:
make a new package with go.mod and a main_test.go file.
put this inside the file

package main_test

import "testing"

type Thing struct {
	Buf [1]byte
}
type Things[T any] struct {
	stuff []T
}

func newThings[ThingType any]() Things[ThingType] {
	return Things[ThingType]{make([]ThingType, 1)}
}
func (things *Things[ThingType]) Get(e int) *ThingType {
	return &things.stuff[0]
}

func BenchmarkTriggerCompilerError(b *testing.B) {
	things := newThings[Thing]()
	for b.Loop() {
		things.Get(1).Buf[0] = 1
	}
}

then trigger the error using go test .

What did you see happen?

…/coding/compilerError ❯ go test .
# main_test [main.test]
../../.local/share/mise/installs/go/1.26.0/src/sync/atomic/type.go:174:6: internal compiler error: panic: interface conversion: ir.Node is *ir.IndexExpr, not *ir.StarExpr

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new
FAIL	main [build failed]
FAIL

What did you expect to see?

The compiler not panicking

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.FixPendingIssues that have a fix which has not yet been reviewed or submitted.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions