mirror of
https://github.com/apple/swift-collections
synced 2026-11-25 04:37:48 +00:00
The guard `slot > 0` incorrectly excluded `slot == 0`, causing the function to return `endIndex` whenever the matching element was at position 0 of any node. Changed to `slot >= 0`. The non-leaf fallback was also missing `offset += slot`, matching the same bug that exists symmetrically in startIndex(forKey:). The absolute offset of element[k] in a non-leaf node is ancestors + sum(subtreeCount[0..k]) + k; the `+k` term was absent. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>