Skip to content

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

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

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

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.

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