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 using type parametrized interface #48648

Closed
guilhem opened this issue Sep 27, 2021 · 2 comments
Closed

cmd/compile: internal compiler error using type parametrized interface #48648

guilhem opened this issue Sep 27, 2021 · 2 comments
Labels
FrozenDueToAge 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.
Milestone

Comments

@guilhem
Copy link

guilhem commented Sep 27, 2021

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

$ go version
go version devel go1.18-6e5dd0b Mon Sep 27 11:52:07 2021 +0000 linux/amd64

Does this issue reproduce with the latest release?

gotip

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/guilhem/.cache/go-build"
GOENV="/home/guilhem/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/guilhem/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/guilhem/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/guilhem/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/guilhem/sdk/gotip/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.18-6e5dd0b Mon Sep 27 11:52:07 2021 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/guilhem/sources/go-workers/go.mod"
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-build3285140924=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Experimenting generics, I had to use a generics interface.

type Out[I any] interface {
	SetOut(c chan I) error
}

type Runner[I, O any] struct {
...
}

func (r *Runner[I,O]) InFrom(w ...Out[I]) *Runner[I,O] {
...
}

func (r *Runner[I,O]) SetOut(c chan O) error {
...
}

https://github.com/guilhem/gorkers/blob/generics/workers.go#L18

running tests should trigger error

What did you see instead?

./workers_test.go:337:2: internal compiler error: NewMethodType with type parameters in signature FUNC-method(*struct {}) func(chan gorkers.I₁₄) error
@mknyszek
Copy link
Contributor

mknyszek commented Oct 4, 2021

CC @griesemer @mdempsky @danscales

@mknyszek mknyszek changed the title generics: internal compiler error with interface cmd/compile: internal compiler error using generic interface Oct 4, 2021
@mknyszek mknyszek changed the title cmd/compile: internal compiler error using generic interface cmd/compile: internal compiler error using type parametrized interface Oct 4, 2021
@mknyszek mknyszek 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 Oct 4, 2021
@mknyszek mknyszek added this to the Go1.18 milestone Oct 4, 2021
@griesemer
Copy link
Contributor

I cannot reproduce this. Both the snippet and the full workers.go file type-check and compile without issue with the latest compiler at tip.

If you have more information on this you can re-open, but I am going to close this for now.

@golang golang locked and limited conversation to collaborators Oct 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge 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.
Projects
None yet
Development

No branches or pull requests

4 participants