Thanks to visit codestin.com
Credit goes to github.com

Skip to content

πŸ› Backport v0.4 SequenceSet bugfixes #461

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

Merged
merged 5 commits into from
Apr 29, 2025

Conversation

nevans added 4 commits April 28, 2025 23:16
The bug was that exclusive ranges ending in zero would be converted to
end on `-1`, which would be interpretted as the last value in the range.
This maybe isn't actually documented very well (or at all...) but most
SequenceSet transform methods return a frozen result when +self+ is
frozen and a mutable result when +self+ is mutable.  Except +limit+
which always returns a frozen result.  And (before this commit) +slice+,
which inconsistently returned with matching frozen status when the
result wasn't empty, but always returned a frozen set when the result
_was_ empty.

Adding these tests exposed a much more significant bug:
`SequenceSet#xor` mutates the reciever.
`set ^ other` and `set.xor other` are supposed to be safe transforms.
But, unfortunately, they modified the receiver if it wasn't frozen, and
crashed when it was!

The fix is trivial: convert `self` to `dup`.
The goal is for `#[]` (aliased as `#slice`) to behave similarly to
`Array#[]`/`Array#slice`.  When `Array#slice` has a length or range that
extends beyond the end of the array, they simply return everything
up to the end.
@nevans nevans changed the title πŸ› Backport v0.4 seqset bugfixes πŸ› Backport v0.4 SequenceSet bugfixes Apr 29, 2025
@nevans nevans force-pushed the backport/v0.4-seqset-bugfixes branch from 659f943 to 06fb071 Compare April 29, 2025 03:28
@nevans nevans added bug Something isn't working backport This issue or PR is for a stable release branch labels Apr 29, 2025
@nevans nevans merged commit e0f997c into v0.4-stable Apr 29, 2025
30 checks passed
@nevans nevans deleted the backport/v0.4-seqset-bugfixes branch April 29, 2025 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport This issue or PR is for a stable release branch bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant