Repository navigation
Add String#append_as_bytes - #450
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
String#append_as_byteswas undefined (NoMethodError). It appends eachargument'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_intcoercion — and any other argument raises aTypeErrornamingits class. A frozen receiver raises
FrozenError.The
TypeErrorusesvm.classOf(arg).namerather than the staticclassNameOf,so a user-defined class instance is named correctly (e.g.
MockObject) insteadof 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_spec0 → 8.🤖 Generated with Claude Code