-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
unique: panic when calling unique.Make with string casted as any #68990
Comments
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
CC @mknyszek |
Looking into it. |
I see the general problem -- it's a classic reflection mistake when trying to get the type of a value (via Easy fix, apologies for the breakage. |
Change https://go.dev/cl/607355 mentions this issue: |
@gopherbot Please open a backport issue for Go 1.23. This problem accidentally limits what types the |
Backport issue(s) opened: #68992 (for 1.23). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
Appreciate the insanely quick response. |
Change https://go.dev/cl/607435 mentions this issue: |
…type in Make Currently the first thing Make does it get the abi.Type of its argument, and uses abi.TypeOf to do it. However, this has a problem for interface types, since the type of the value stored in the interface value will bleed through. This is a classic reflection mistake. Fix this by implementing and using a generic TypeFor which matches reflect.TypeFor. This gets the type of the type parameter, which is far less ambiguous and error-prone. For #68990. Fixes #68992. Change-Id: Idd8d9a1095ef017e9cd7c7779314f7d4034f01a7 Reviewed-on: https://go-review.googlesource.com/c/go/+/607355 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> (cherry picked from commit 755c18e) Reviewed-on: https://go-review.googlesource.com/c/go/+/607435 Reviewed-by: Ian Lance Taylor <iant@google.com>
Go version
go version go1.23.0 linux/amd64
Output of
go env
in your module/workspace:What did you do?
Casting a string to
any
and passing it tounique.Make
seems to cause issues.Example crash 1
unexpected fault address 0x912c08
: https://go.dev/play/p/vZWwiXU6YXLExample crash 2
panic: interface conversion: interface {} is *unique.uniqueMap[string], not *unique.uniqueMap[interface {}]
: https://go.dev/play/p/U8JvXsqXpJQWhat did you see happen?
For it not to crash
What did you expect to see?
I expected to see nothing and the program not to crash
The text was updated successfully, but these errors were encountered: