Repository navigation
vm: name anonymous classes in inspect and FrozenError; Set subclass inspect - #993
Merged
Merged
Conversation
…nspect
rb_obj_inspect, rb_any_to_s and the FrozenError message name the class
through rb_class_name, which renders an anonymous class as its
"#<Class:0x…>" identity. rbgo read the empty name and printed "#<:0x…>"
and "can't modify frozen : …". A new vm.classPath does what rb_class_name
does and the three paths use it.
set_i_inspect (set.c, v4.0.10) prints the "Set[…]" literal form for Set
itself only; a subclass keeps "#<Foo: {1, 2}>", with "#<Foo: {...}>" as
its recursion marker. rbgo printed "Set[…]" for both. Set's repr now takes
the VM to name an anonymous subclass and to inspect each member through
Ruby, and Kernel#p / inspectStr dispatch a Set's #inspect, so a member's
own #inspect and a subclass override are honoured, as rb_inspect does.
Measured against MRI 4.0.10 with rubydiff on 29 lines: AGREE.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ubuntu coverage ratchet put Set#Inspect and repr at 0% and reprWith at 94.7%: once Ruby's Set#inspect went through reprWith(vm), nothing in the suite read the VM-less path a host program or a Go-side message uses. TestSetGoInspect drives it for Set itself, a subclass and a Set that contains itself, in set_i_inspect's MRI 4.0.10 shapes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tannevaled
force-pushed
the
set-inspect
branch
from
November 29, 2026 17:33
0b661b7 to
42c90b1
Compare
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.
What
Anonymous classes.
rb_obj_inspect,rb_any_to_sand theFrozenErrormessage name the class throughrb_class_name, which renders an anonymous class as its#<Class:0x…>identity. rbgo read the emptynamefield instead:Class.new.new.inspect#<:0x…>#<#<Class:0x…>:0x…>Class.new.new.to_s#<:0x…>#<#<Class:0x…>:0x…>instance_variable_setcan't modify frozen : #<:0x…>can't modify frozen #<Class:0x…>: #<#<Class:0x…>:0x…>A new
vm.classPathdoes whatrb_class_namedoes, and those three paths use it.Set subclasses.
set_i_inspect(set.c, v4.0.10) prints theSet[…]literal form for Set itself only. A subclass keeps the older shape,#<Foo: {1, 2}>, with#<Foo: {...}>as its recursion marker; rbgo printedSet[…]for both. Set's repr now takes the VM, which lets it:Kernel#pandinspectStrnow dispatch a Set's#inspect. As a result,p Set[obj]showsobj's own#inspect, and a subclass's#inspectoverride is honoured, asrb_inspectdoes.Evidence
rubydiffagainst MRI 4.0.10 (ruby 4.0.10 (2026-11-19 revision a704b7cd95) +PRISM [arm64-darwin27]) on a 29-line probe: AGREE. The probe covers named and anonymous subclasses, nesting in Set, Array and Hash, recursion, a namespacedOuter::Set, member#inspect, a subclass#inspectoverride, and plainSetunchanged.Tests
TestAnonymousClassInspectandTestSetSubclassInspecttake MRI's output as their expectations.Inspect|Set|Frozen|Freeze|Anonymous|ToS|Kernel|Struct|Data|Exception|Error): 838 tests ran, none failed.-sites all) on the four new branches: all caught.Once #992 (Set freeze) is in, a frozen subclass's error also reads
can't modify frozen Foo: #<Foo: {1}>, which the probe measured as matching MRI. It is not asserted here, because this branch has no Set freeze.Refs #992
🤖 Generated with Claude Code