-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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: using generics with -buildmode=plugin results in compiler crash #52937
Comments
|
I assume we don't expect package plugin to be able to access generic functions? If so, seems like this should be an easy fix. |
Certainly the plugin package is not going to be able to access an uninstantiated generic function. It's likely that it also shouldn't be able to access an instantiated version of a generic function. |
Change https://go.dev/cl/406358 mentions this issue: |
FWIW, the workaround for this in Go 1.18 is to not declare exported generic functions in your main package. E.g., rename I don't think this needs a backport to Go 1.18. It's something that has never worked (generics didn't exist prior to Go 1.18), only affects plugins (which are relatively unused/unsupported anyway), and there's an easy workaround (rename affected functions in a single package). If anyone else disagrees though, feel free to request a backport. The CL should cleanly apply to the 1.18 release branch. |
I was actually hoping on a lark that this would work inside a plugin, but it makes sense why it wouldn't. It's easy enough to use |
Change https://go.dev/cl/406774 mentions this issue: |
CL 406358 added test that use -buildmode=plugin. But plugin mode only supports on some os/arch pairs, so this CL moving the test to misc/cgo/testplugin directory instead. Updates #52937 Change-Id: Iad049443c1f6539f6af1988bebd4dff56c6e1bf9 Reviewed-on: https://go-review.googlesource.com/c/go/+/406774 Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I can compile this plugin:
But if I change
Foo
toFoo[T any]
I get a compiler error:What did you expect to see?
I expected it to compile a
foo.so
plugin file.What did you see instead?
./main.go:4:9: internal compiler error: writeType func[Foo.T](Foo.T) Foo.T
The text was updated successfully, but these errors were encountered: