-
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
slices: Insert function does not panic if i is out of range and there are no values to insert #63913
Comments
The documentation does indeed claim that it will panic: (attn @ianlancetaylor @eliben) |
Interesting edge case. I looked back at the original implementation of |
Making it panic in these cases is fine. |
Change https://go.dev/cl/540155 mentions this issue: |
Change https://go.dev/cl/542455 mentions this issue: |
The panic message of the current implementation for index out of range is not ideal. This PR tries to improve it. Fixes #63913 and #64152 Change-Id: Ibcf6c9c0f555c8b8bf46b7d6f20f0ccc5698acd4 GitHub-Last-Rev: 1bbec23 GitHub-Pull-Request: #64163 Reviewed-on: https://go-review.googlesource.com/c/go/+/542455 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org>
The
slices.Insert
function should panic ifi
is out of range, but it does not panic if there are no values to insert:The text was updated successfully, but these errors were encountered: