Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jammer312 opened this issue Jul 21, 2022 · 3 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge generics Issue is related to generics NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@jammer312
Copy link

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.

@jammer312 jammer312 changed the title internal compiler error: panic: runtime error: index out of range [1] with length 1 when compiling code with unbound method of generic type runtime: internal compiler error: panic: runtime error: index out of range [1] with length 1 when compiling code with unbound method of generic type Jul 21, 2022
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 21, 2022
@jammer312 jammer312 changed the title runtime: internal compiler error: panic: runtime error: index out of range [1] with length 1 when compiling code with unbound method of generic type cmd/compile: internal compiler error: panic: runtime error: index out of range [1] with length 1 when compiling code with unbound method of generic type Jul 21, 2022
@toothrot toothrot added generics Issue is related to generics NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jul 22, 2022
@toothrot toothrot added this to the Backlog milestone Jul 22, 2022
@cuonglm cuonglm changed the title cmd/compile: internal compiler error: panic: runtime error: index out of range [1] with length 1 when compiling code with unbound method of generic type cmd/compile: internal compiler error when compiling code with unbound method of generic type Jul 22, 2022
@gopherbot
Copy link

Change https://go.dev/cl/419294 mentions this issue: cmd/compile: fix wrong typeparams for selector expr with embedded generic type

@prattmic prattmic modified the milestones: Backlog, Go1.20 Jul 27, 2022
@prattmic prattmic added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jul 27, 2022
@randall77
Copy link
Contributor

@gopherbot Please open a backport issue for 1.19.

@gopherbot
Copy link

Backport issue(s) opened: #54243 (for 1.19).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge generics Issue is related to generics NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants