NoMethodError#message renders the receiver via its Ruby-level #name#895
Merged
Conversation
core/exception (minus Process.kill-to-self files): 13 -> 10 failures.
CRuby builds a NoMethodError message by calling the receiver's (or, for
an ordinary object, its class's) #name — so a class/module with an
overridden 'def self.name' shows that name rather than its anonymous
'#<Class:0x...>' form. monoruby baked the message from the internal
class name at raise time. Rebuild it in the default method_missing
handler (which has an Executor) for genuine 'undefined method' errors:
- class / module receiver -> 'class <#name>' / 'module <#name>'
(anonymous -> the '#<Class:0x...>' form);
- receiver with its own singleton class -> its object string form
('for #<Klass:0x...>');
- ordinary object -> 'an instance of <class #name>'.
The rendering goes through #name only, never #inspect (a spec asserts
#inspect is not called). Visibility errors (private/protected method
called) keep their own message and are excluded via an flag,
so only real missing-method errors are re-rendered and carry #args.
New differential tests in tests/no_method_error_message.rs.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XpzdoFu46d2ChJpSzeWsNK
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #895 +/- ##
=======================================
Coverage 90.48% 90.49%
=======================================
Files 189 189
Lines 123128 123170 +42
=======================================
+ Hits 111416 111460 +44
+ Misses 11712 11710 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
Continues the ruby/spec compliance work (#891, #893, #894), closing the
NoMethodError#messagereceiver-rendering gap in the core/exception category (CRuby 4.0.2 reference). Excluding the four spec files thatProcess.killthe runner itself, the category goes from 13 → 10 failures.Change
CRuby builds a
NoMethodErrormessage by calling the receiver's — or, for an ordinary object, its class's — Ruby-level#name. So a class/module with an overriddendef self.nameshows that name rather than its anonymous#<Class:0x…>form. monoruby baked the message from the internal class name at raise time, which is wrong for that case.The message is now rebuilt in the default
method_missinghandler (which has anExecutor) for genuineundefined methoderrors:class <#name>/module <#name>(anonymous → the#<Class:0x…>form);for #<Klass:0x…>);an instance of <class #name>.The rendering goes through
#nameonly, never#inspect(a spec asserts#inspectis not called during message building). Visibility errors (private/protected method … called) keep their own message and are excluded via anundefinedflag, so only real missing-method errors are re-rendered (and carry#args).Testing
tests/no_method_error_message.rs(4, comparing against CRuby — named class/module/instance, nil/true/false/Integer receivers, the no-#inspectguarantee, and unchanged private/protected messages).cargo test --lib --tests: green (a couple of transientLoadError/timeout flakes from concurrentbuild.rsreinstalls during local iteration, not from this change).Remaining (out of scope here)
Exception#backtracesecond-element/format details and backtrace-array identity (~7 specs) and top-level cause printing (2) — both need backtrace-representation work.Process.killto self) — design decision indoc/signal_handling.md.🤖 Generated with Claude Code
https://claude.ai/code/session_01XpzdoFu46d2ChJpSzeWsNK
Generated by Claude Code