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

Comments

@guilhem
Copy link

@guilhem 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 mknyszek commented Oct 4, 2021

Loading

@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 this to the Go1.18 milestone Oct 4, 2021
@griesemer
Copy link
Contributor

@griesemer griesemer commented Oct 4, 2021

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.

Loading

@griesemer griesemer closed this Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants