-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: compiler crash with "Dictionary should have already been generated" #52279
Comments
A simpler version of lib.go that doesn't require an import but still recreates the problem: // lib/lib.go
package lib
type Map[K comparable, V any] map[K]V
type FMap[K, V comparable] Map[K, V]
func (m FMap[K, V]) Flip() FMap[V, K] {
out := make(FMap[V, K])
for k, v := range m {
out[v] = k
}
return out
}
type MyType uint8
const (
FIRST MyType = iota
)
var typeStrs = FMap[MyType, string]{
FIRST: "FIRST",
}
func (self MyType) String() string {
str, exists := typeStrs[self]
if !exists {
return "UNKNOWN"
}
return str
} |
@gopherbot Please open a backport to 1.18 This looks like a compiler crash on valid code. |
Backport issue(s) opened: #52286 (for 1.18). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
Repro on playground: https://go.dev/play/p/lFHvAeGwc1g?v=gotip |
I'm looking at this, as part of my "learn generics by playing with bugs", and I see (with two debugging booleans set and -W=2)
Where the missing dictionary is Do I read this correctly as an export/import problem? |
Still slogging, intermittent with other work, but with Error messages suggest however that I am compiling package "bug" and that perhaps the value of the current function is stale? The bug does not reproduce when inlining is turned off. |
Further work. A simpler version of lib/lib.go:
Uncomment F at the bottom to make it pass; I think this is an export problem, where the exported inline for |
Change https://go.dev/cl/405118 mentions this issue: |
Change https://go.dev/cl/405543 mentions this issue: |
…ture When a fully instantiated generic method is exported, be sure to also export the types in its signature. Updates #52279. Fixes #52286. Change-Id: Icc6bca05b01f914cf67faaf1bf184eaa5484f521 Reviewed-on: https://go-review.googlesource.com/c/go/+/405118 Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> (cherry picked from commit 1284cc2) Reviewed-on: https://go-review.googlesource.com/c/go/+/405543 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
What version of Go are you using (
go version
)?1.18
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?What did you do?
Tried using this generic method
go.structs.dev/gen/FMap.Flip()
cross-package and received the following error:Here is a complete reproducible version:
bug.tar.gz
What did you expect to see?
I expected it to compile and be able to use the flipped map as a normal type aliased
go.structs.dev/gen/Map
What did you see instead?
Got this error:
The text was updated successfully, but these errors were encountered: