Skip to content

Add String#append_as_bytes - #450

Merged
tannevaled merged 1 commit into
mainfrom
feat/cluster22
Aug 25, 2026
Merged

tannevaled merged 1 commit into
mainfrom
feat/cluster22

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

String#append_as_bytes was undefined (NoMethodError). It appends each
argument's bytes to the receiver in place, never changing its encoding (so the
result may become invalidly encoded): a String argument contributes its raw
bytes, and an Integer argument its least-significant byte (Bignums and negative
values wrap mod 256). Only String and Integer are accepted — there is no
#to_str/#to_int coercion — and any other argument raises a TypeError naming
its class. A frozen receiver raises FrozenError.

The TypeError uses vm.classOf(arg).name rather than the static classNameOf,
so a user-defined class instance is named correctly (e.g. MockObject) instead
of falling back to Object.

Verified against ruby 4.0.6. Full package coverage stays at 100.0%.
Zero-regression rubyspec sweep; core/string/append_as_bytes_spec 0 → 8.

🤖 Generated with Claude Code

String#append_as_bytes was undefined (NoMethodError). It appends each argument's
bytes to the receiver in place, never changing its encoding (so the result may
become invalidly encoded): a String argument contributes its raw bytes, and an
Integer argument its least-significant byte (Bignums and negative values wrap
mod 256). Only String and Integer are accepted — there is no #to_str/#to_int
coercion — and any other argument raises a TypeError naming its class. A frozen
receiver raises FrozenError.

The TypeError uses vm.classOf(arg).name rather than the static classNameOf, so a
user-defined class instance is named correctly (e.g. "MockObject") instead of
falling back to "Object".

Verified against ruby 4.0.6. Full package coverage stays at 100.0%. Zero-
regression rubyspec sweep; core/string/append_as_bytes_spec 0 -> 8.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit ddaf22f into main Aug 25, 2026
7 checks passed
@tannevaled
tannevaled deleted the feat/cluster22 branch August 25, 2026 10:31
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