mirror of
https://github.com/apple/swift-collections
synced 2026-11-22 04:20:40 +00:00
`maskingShiftLeft(by:)`, `maskingShiftRight(by:)` and `resizingShiftLeft(by:)` handle a negative amount by negating it and shifting the other way, so `Int.min` trapped with an arithmetic overflow. All three have a defined result for it: an amount of at least `count` clears or removes every value, which is what `Int.min + 1` already did. Clamp the magnitude of a negative amount to `Int.max` in these three. `resizingShiftRight(by:)` is left alone: a negative amount inserts values there, and no array can hold as many as `Int.min` asks for. The masking shifts had no tests. Add tests for both of them over word-crossing counts and amounts on either side of `count`, for their doc examples, and for the extreme amounts. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>