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

Open
jammer312 opened this issue Jul 21, 2022 · 3 comments
Assignees
Labels
compiler/runtime generics NeedsFix
Milestone

Comments

@jammer312
Copy link

@jammer312 jammer312 commented Jul 21, 2022

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 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 NeedsInvestigation 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

@gopherbot gopherbot commented Jul 23, 2022

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 and removed NeedsInvestigation labels Jul 27, 2022
@randall77
Copy link
Contributor

@randall77 randall77 commented Aug 3, 2022

@gopherbot Please open a backport issue for 1.19.

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 3, 2022

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime generics NeedsFix
Projects
Status: In Progress
Development

No branches or pull requests

6 participants