Skip to content

Conversation

@LeoNavel
Copy link
Contributor

@LeoNavel LeoNavel commented Jan 4, 2024

_BTree.removeFirst(_:) and _BTree.removeLast(_:) contains following incorrect assert:

assert(0 <= k && k < self.count, "Can't remove more items from a collection than it contains")

This assertion will cause a crash (in debug mode) when we call one of these functions with the same number of items as the collection contains.

This PR solves this issue by replacing k < self.count with k <= self.count in the assert.

Checklist

  • I've read the Contribution Guidelines
  • My contributions are licensed under the Swift license.
  • I've followed the coding style of the rest of the project.
  • I've added tests covering all new code paths my change adds to the project (if appropriate).
  • I've added benchmarks covering new functionality (if appropriate).
  • I've verified that my change does not break any existing tests or introduce unexplained benchmark regressions.
  • I've updated the documentation if necessary.

@LeoNavel LeoNavel requested a review from lorentey as a code owner January 4, 2024 08:24
Copy link
Member

@lorentey lorentey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 👍

@lorentey
Copy link
Member

lorentey commented Jan 4, 2024

@swift-ci test

@lorentey lorentey merged commit 427083e into apple:main Jan 30, 2024
@lorentey lorentey added this to the 1.3.0 milestone Sep 27, 2025
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.

2 participants