Repository navigation
🐛 Fix SequenceSet#[] with valid positive range.begin but invalid negative range.end - #776
Open
nevans wants to merge 1 commit into
Conversation
nevans
added this pull request to stack #775
October 3, 2026 00:33
When slicing with a positive...negative range, where the range ends prior to the beginning of the set, this incorrectly set `max` to the _last_ value in the set, without regarding the sign of the range end. This converts both `set[start..end]` and `set[start..-end]` into `set[start..]` when the range end is out of range, which is correct for positive range end, but clearly incorrect for negative range end.
nevans
force-pushed
the
sequence_set/fix-slice-range-pos-to-out-of-range-neg
branch
from
October 3, 2026 13:42
ada5632 to
b546855
Compare
SequenceSet#slice(pos..too_low_neg)SequenceSet#[] for range with valid positive begin, but invalid negative end
SequenceSet#[] for range with valid positive begin, but invalid negative endSequenceSet#[] with valid positive range.begin but invalid negative range.end
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When slicing with a
positive..negativerange, where the range ends prior to the beginning of the set,SequenceSet#sliceincorrectly setmaxto the last value in the set, without regarding the sign of the range end. This converted bothset[first..last]andset[first..-last]intoset[first..]when the range end is out of range, which is correct for positive range end, but clearly incorrect for negative range end.This PR fixes that, by treating a missing negative
maxas0, e.g: identical toset[first...0]. Assumingfirst.abs <= cardinality, this will return an empty set.