Skip to content

Avoid eagerly inspecting call traces in type assertions - #3073

Merged
soutaro merged 1 commit into
ruby:masterfrom
Shopify:codex/lazy-assert-send-type-message
Aug 10, 2026
Merged

Avoid eagerly inspecting call traces in type assertions#3073
soutaro merged 1 commit into
ruby:masterfrom
Shopify:codex/lazy-assert-send-type-message

Conversation

@soutaro

@soutaro soutaro commented Aug 10, 2026

Copy link
Copy Markdown
Member

RBS::UnitTest::TypeAssertions eagerly interpolates trace.inspect into assertion messages, so the complete argument and return values are inspected even when the assertion succeeds.

This is problematic for ObjectSpace.reachable_objects_from_root: after the per-Ractor GC roots change in Ruby, the returned roots hash can be very large. Building its inspection string causes excessive peak memory usage and can raise NoMemoryError in the Windows test-bundled-gems job in ruby/ruby.

Pass assertion messages as procs so call traces and method definitions are formatted only when an assertion fails. Apply the same lazy formatting to assert_send_type, assert_send_type_error, and refute_send_type.

@soutaro
soutaro force-pushed the codex/lazy-assert-send-type-message branch 2 times, most recently from 791275e to 9dddf8d Compare August 10, 2026 02:18
@soutaro
soutaro enabled auto-merge August 10, 2026 02:19
@soutaro
soutaro force-pushed the codex/lazy-assert-send-type-message branch from 9dddf8d to f1bcff3 Compare August 10, 2026 02:28
@soutaro
soutaro added this pull request to the merge queue Aug 10, 2026
Merged via the queue into ruby:master with commit da71a3b Aug 10, 2026
24 checks passed
@soutaro
soutaro deleted the codex/lazy-assert-send-type-message branch August 10, 2026 02:34
soutaro added a commit that referenced this pull request Aug 10, 2026
Backport #3073 to 4.1: Avoid eagerly inspecting call traces in type assertions
@soutaro soutaro mentioned this pull request Aug 10, 2026
@soutaro soutaro mentioned this pull request Aug 18, 2026
soutaro pushed a commit that referenced this pull request Aug 23, 2026
`RBS::VERSION` becomes 4.2.0, `Gemfile.lock` is regenerated with the bump,
and the 4.2.0.pre.1 section of CHANGELOG.md is replaced by the 4.2.0
section that folds it in.

The changelog starts at `v4.1.2`, the latest release proper reachable from
`master`: a release proper skips the prerelease tags, so everything written
up under 4.2.0.pre.1 is in this section as well. #3074 and #3073 appear
under 4.1.3 too, which backported them.

Co-Authored-By: Claude <noreply@anthropic.com>
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