Repository navigation
Implement Range.new - #423
Merged
Merged
Conversation
Range.new was not defined, so it fell through to the generic Class#new
and produced a bare Range instance with no range data; every Range
method then panicked ("interface conversion: *vm.RObject is not
*object.Range"), and any spec constructing a range with Range.new
crashed on first use.
Range.new(begin, end, exclude_end = false) now builds a proper Range
value: the third argument is exclusive when truthy (MRI treats any
non-false value as exclusive, e.g. Range.new(1, 3, 1)); the endpoints
must be comparable with #<=> unless one is nil (a beginless or endless
range), a nil comparison raising ArgumentError "bad value for range"
and an exception from #<=> propagating; and a subclass instance wraps
the range so a Range subclass constructs correctly.
Verified against ruby 4.0.6; this unblocks language/range_spec (1 -> 5)
and core/range/exclude_end_spec (0 -> 2), among others, with no
regressions.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Range.newwas not defined, so it fell through to the genericClass#newand produced a bareRangeinstance with no range data;every
Rangemethod then panicked (interface conversion: *vm.RObject is not *object.Range), and any code constructing a range withRange.newcrashed on first use.Range.new(begin, end, exclude_end = false)now builds a properRangevalue:
non-false value as exclusive, e.g.
Range.new(1, 3, 1));#<=>unless one isnil(abeginless or endless range) — a
nilcomparison raisesArgumentError "bad value for range", and an exception from#<=>propagates;
Rangesubclass constructscorrectly.
Verified against ruby 4.0.6; this unblocks
language/range_spec(
1 → 5) andcore/range/exclude_end_spec(0 → 2), among others. Thewhole-suite coverage gate stays at 100.0% and a full language+core sweep
shows no regressions.
🤖 Generated with Claude Code