Skip to content

cmd/compile: internal compiler error: cannot call SetType(go.shape.int) on v (type int)  #59378

@abursavich

Description

@abursavich

What version of Go are you using (go version)?

$ go version
go version go1.20.2 darwin/arm64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/REDACTED/Library/Caches/go-build"
GOENV="/Users/REDACTED/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/REDACTED/go/pkg/mod"
GONOPROXY="REDACTED"
GONOSUMDB="REDACTED"
GOOS="darwin"
GOPATH="/Users/REDACTED/go"
GOPRIVATE="REDACTED"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.2"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="REDACTED"
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 -fdebug-prefix-map=/var/folders/p4/t2ydl1qj10s99sfykmbnp6cc0000gq/T/go-build2434621046=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I was working on a package that uses generics. I changed a call from slices.ContainsFunc to slices.IndexFunc and it stopped compiling. The actual code was fairly complicated, but I've reduced it down to this nonsensical repro:

https://go.dev/play/p/-3mq-tXI8lI

package main

import "golang.org/x/exp/slices"

func main() {
	compilerError([]int{}, func(int) bool { return true })
}

func compilerError[S []E, E any](a S, fn func(E) bool) {
	for _, v := range a {
		// The error doesn't occur with slices.ContainsFunc
		slices.IndexFunc(a, func(e E) bool { return fn(v) })
	}
}
go: finding module for package golang.org/x/exp/slices
go: downloading golang.org/x/exp v0.0.0-20230321023759-10a507213a29
go: found golang.org/x/exp/slices in golang.org/x/exp v0.0.0-20230321023759-10a507213a29
# play
./prog.go:10:9: internal compiler error: cannot call SetType(go.shape.int) on v (type int)

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

What did you expect to see?

I expected the code to keep compiling.

What did you see instead?

REDACTED:393:9: internal compiler error: cannot call SetType(go.shape.int) on v (type int)

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

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions