Skip to content

unique: panic when calling unique.Make with string casted as any [1.23 backport] #68992

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

Closed
gopherbot opened this issue Aug 21, 2024 · 2 comments
Labels
CherryPickApproved Used during the release process for point releases
Milestone

Comments

@gopherbot
Copy link
Contributor

@mknyszek requested issue #68990 to be considered for backport to the next 1.23 minor release.

@gopherbot Please open a backport issue for Go 1.23.

This problem accidentally limits what types the unique package can work with, and results in panics. Also, the fix is very simple and low risk.

@gopherbot gopherbot added the CherryPickCandidate Used during the release process for point releases label Aug 21, 2024
@gopherbot gopherbot added this to the Go1.23.1 milestone Aug 21, 2024
@gopherbot
Copy link
Contributor Author

Change https://go.dev/cl/607435 mentions this issue: [release-branch.go1.23] unique: use TypeFor instead of TypeOf to get type in Make

@cherrymui cherrymui added the CherryPickApproved Used during the release process for point releases label Aug 21, 2024
@gopherbot gopherbot removed the CherryPickCandidate Used during the release process for point releases label Aug 21, 2024
gopherbot pushed a commit that referenced this issue Aug 21, 2024
…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 <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
(cherry picked from commit 755c18e)
Reviewed-on: https://go-review.googlesource.com/c/go/+/607435
Reviewed-by: Ian Lance Taylor <[email protected]>
@gopherbot
Copy link
Contributor Author

Closed by merging CL 607435 (commit 76346b3) to release-branch.go1.23.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CherryPickApproved Used during the release process for point releases
Projects
None yet
Development

No branches or pull requests

2 participants