Skip to content

cmd/compile: internal compiler error when compiling code with unbound method of generic type #53982

Closed
@jammer312

Description

@jammer312

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

$ go version
go version go1.18.3 linux/amd64

$ go version
go version go1.18.4 linux/amd64

Does this issue reproduce with the latest release?

Does reproduce on go1.18.4 linux/amd64, also reproduces on go.dev/play

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jammer312/.cache/go-build"
GOENV="/home/jammer312/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/jammer312/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jammer312/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/jammer312/sdk/go1.18.4"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/jammer312/sdk/go1.18.4/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.4"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/jammer312/compilerError/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3256653741=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Tried to compile this (go build):
https://go.dev/play/p/WO6ZxYH7P3a
(go playground fails to compile it too)

What did you expect to see?

Either some description of what is wrong with the code or successful compilation.

What did you see instead?

# compilerError
./main.go:98:15: internal compiler error: panic: runtime error: index out of range [1] with length 1

Replacing unbound method ((*dataWithTimestamp[valueType, value]).Timestamped) with a function that does pretty much the same (converts *dataWithTimestamp[valueType, value] to Timestamped[value]) allows it to compile.

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.genericsIssue is related to generics

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions