Skip to content

Implement Range.new - #423

Merged
tannevaled merged 1 commit into
mainfrom
feat/cluster4
Aug 21, 2026
Merged

tannevaled merged 1 commit into
mainfrom
feat/cluster4

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

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 code 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 raises
    ArgumentError "bad value for range", and an exception from #<=>
    propagates;
  • 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. The
whole-suite coverage gate stays at 100.0% and a full language+core sweep
shows no regressions.

🤖 Generated with Claude Code

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>
@tannevaled
tannevaled merged commit 0897057 into main Aug 21, 2026
7 checks passed
@tannevaled
tannevaled deleted the feat/cluster4 branch August 21, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant