Skip to content

[4.0][stdlib] Fix array slice self-assignment bug #11022

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

Conversation

airspeedswift
Copy link
Member

Cherry pick of #10958 onto the 4.0 branch.

  • Explanation: When fast-pathing in-place slice mutation, bounds check the slice's ranges match exactly. In-place mutation of an array slice doesn't need assigning back, but there needs to be a check that the assigned slice's bounds matches otherwise unmatched range assignments like a[1..<1] = a[1..<2] were getting thrown away.
  • Scope of Issue: Correctness fix
  • Risk: Minimal. This is checking for a potential no-op fast path. When the check fails, the full replaceRange method is called, writing the slice into the collection in full. This is what is desired in this case.
  • Reviewed By: Dave Abrahams
  • Testing: Automated test suite + new tests for this case

Fix bug where assigning from self wasn't checking bounds of the assigned slice matched
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant