Skip to content

Revert IO::Buffer subclass-preserving types for ruby-head - #3196

Merged
ksss merged 1 commit into
ruby:masterfrom
ksss:io-buffer-drop-subclass-types
Oct 5, 2026
Merged

ksss merged 1 commit into
ruby:masterfrom
ksss:io-buffer-drop-subclass-types

Conversation

@ksss

@ksss ksss commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

stdlib_test on ruby-head started failing in the merge queue (e.g. for #3193) after ruby/ruby 5b6f593531 ("Introduce (internal) IO::Buffer::Storage and Slice") landed. IO::Buffer no longer has an allocator, IO::Buffer.new became a factory for IO::Buffer::Storage, and .for/.string raise Storage factory requires IO::Buffer::Storage! for any class that is not a Storage subclass. The tests added in #3190 use Class.new(IO::Buffer), which now fails with allocator undefined.

That design is marked internal and is likely to change, so rather than branching on the Ruby version this PR drops the subclass-dependent parts:

  • IO::Buffer.for, IO::Buffer.string, #slice and #transfer go back to returning/yielding Buffer instead of instance/self.
  • The optional-argument forms of #slice are kept.
  • BufferSubclass is removed from the tests; the self-returning methods (and!, each, ...) are tested with plain IO::Buffer instances.

Test plan

  • bundle exec ruby -Ilib bin/test_runner.rb test/stdlib/io/Buffer_test.rb passes locally on Ruby 4.0.6 (42 tests, 0 failures).
  • ruby-head behaviour was read from the upstream diff, not run locally; the stdlib_test job on this PR should confirm it.

🤖 Generated with Claude Code

…ests

ruby-head (5b6f593531, "Introduce (internal) IO::Buffer::Storage and Slice")
removed the allocator from IO::Buffer and made Storage the allocatable
subclass. The test-only `Class.new(IO::Buffer)` subclass can no longer be
instantiated, and IO::Buffer.for/.string reject it, which broke the
stdlib_test job on ruby-head.

Since that design is still internal and likely to change, go back to the
plain `Buffer` types for IO::Buffer.for, .string, #slice and #transfer, and
exercise the remaining `self`-returning methods with plain IO::Buffer
instances. The optional-argument forms of #slice are kept.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@ksss
ksss added this pull request to the merge queue Oct 5, 2026
Merged via the queue into ruby:master with commit 884b0e9 Oct 5, 2026
24 checks passed
@ksss
ksss deleted the io-buffer-drop-subclass-types branch October 5, 2026 06:21
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