Skip to content

Accept open-ended typed ranges in runtime checks - #3138

Closed
OskarEichler wants to merge 2 commits into
ruby:masterfrom
OskarEichler:codex/open-ended-ranges
Closed

Accept open-ended typed ranges in runtime checks#3138
OskarEichler wants to merge 2 commits into
ruby:masterfrom
OskarEichler:codex/open-ended-ranges

Conversation

@OskarEichler

@OskarEichler OskarEichler commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Runtime checking for Range[T] validates both endpoints as T. Beginless and endless ranges use nil for one endpoint, so valid Range[Integer] values such as ..10 and 1.. are rejected.

Treat a missing endpoint as the range boundary marker and validate only endpoints that are present. The nil check uses the runtime checker's Test.call primitive so it also supports minimal BasicObject endpoint doubles exercised by RBS.

Verification

  • baseline model rejects valid beginless/endless ranges; the corrected candidate accepts them while retaining endpoint type checks
  • minimal endpoint-object model passes without calling nil? directly
  • Ruby 4 stdlib: 3,072 tests / 56,465 assertions / 0 failures / 0 errors; CGI 2/20, Ractor 22/140, Encoding 45/1,394 also pass
  • all 109 runtime files compile on Ruby 4.0.6
  • focused candidate syntax, RuboCop, and diff checks pass

Source-only change; no test file is included.

@soutaro soutaro self-assigned this Sep 7, 2026
@soutaro

soutaro commented Sep 7, 2026

Copy link
Copy Markdown
Member

This is intentional. Optional range value type is for open-ended values.

@soutaro soutaro closed this Sep 7, 2026
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.

2 participants