Repository navigation
vm: singleton_method and public_method raise MRI's NameError - #985
Merged
Merged
Conversation
Object#singleton_method named the receiver's class ("for Foo") where MRI
names the receiver itself ("for 'FOO!'", proc.c rb_obj_singleton_method
with '%2$s'), and set neither NameError#name nor #receiver.
Object#public_method said "for Foo" / "is not public" where MRI raises
through rb_print_undef / rb_print_inaccessible on CLASS_OF(receiver):
"for class 'Foo'", "is private" / "is protected", with that class -- the
singleton class when there is one -- as #receiver.
nameErrMesgRecv renders '%2$s' as error.c name_err_mesg_to_str does:
nil/true/false literally, a class or module by #name, anything else by
#inspect through #to_s, and rb_any_to_s when #inspect raises.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The coverage ratchet on ubuntu read nameErrMesgRecv at 92.9%: the re-panic of a non-RubyError value in its recover was never reached. The new whitebox test gives the class a native #name that panics with a Go value and asserts the panic reaches the caller unchanged instead of being rendered as "#<Class:0x...>". Control (same -run, the new test skipped): 92.9%; with it: 100.0%. Co-Authored-By: Claude Opus 5.5 <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.
What
Object#singleton_methodandObject#public_methodnow raise theNameErrorMRI 4.0.10 raises.Foo.new.singleton_method(:nope)(inspect →FOO!)undefined singleton method 'nope' for Foo, no#name/#receiverundefined singleton method 'nope' for 'FOO!',name == :nope,receiver.equal?(obj)Foo.new.public_method(:priv)... for Foo is not publicmethod 'priv' for class 'Foo' is private,receiver == FooFoo.public_method(:nope)... for Fooundefined method 'nope' for class '#<Class:Foo>'How
singleton_methodfollowsrb_obj_singleton_method(proc.c v4.0.9:2362): the message names the receiver through'%2$s', and#name/#receiverare set.public_methodfollowsrb_print_undef/rb_print_inaccessibleonCLASS_OF(receiver): "for class '…'", "is private" / "is protected", with that class as#receiver. For a class receiver, or an object with a singleton class, that class is the singleton class.nameErrMesgRecvrenders'%2$s'the wayname_err_mesg_to_strdoes (error.c v4.0.10:2633-2655):nil,trueandfalseprint literally;#name, not its#inspect;#inspectthrough#to_s, so an#inspectreturning 42 shows as'42';#name/#inspectraises, it falls back torb_any_to_s.Evidence
rubydiff -a rbgo -b ruby 4.0.10, using three probe programs that cover 17 receivers:origin/main(ed535866): DIVERGE.internal/vm/name_error_receiver_test.gotake their expected text from MRI 4.0.10's own output.truereceiver, no class whose#inspectdiffers from#name, and a redundant class branch in the fallback). Two of them got test cases; the redundant branch was removed.gofmt -l: clean.The full local
go test ./internal/vm/hit the 10-minute package timeout at load average 145, with no test failing. CI is the measurement here.🤖 Generated with Claude Code