Skip to content

NoMethodError#message renders the receiver via its Ruby-level #name#895

Merged
sisshiki1969 merged 1 commit into
masterfrom
claude/cruby-4-0-2-specs-olt61c
Jul 12, 2026
Merged

NoMethodError#message renders the receiver via its Ruby-level #name#895
sisshiki1969 merged 1 commit into
masterfrom
claude/cruby-4-0-2-specs-olt61c

Conversation

@sisshiki1969

Copy link
Copy Markdown
Owner

Summary

Continues the ruby/spec compliance work (#891, #893, #894), closing the NoMethodError#message receiver-rendering gap in the core/exception category (CRuby 4.0.2 reference). Excluding the four spec files that Process.kill the runner itself, the category goes from 13 → 10 failures.

Change

CRuby builds a NoMethodError message by calling the receiver's — or, for an ordinary object, its class's — Ruby-level #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, which is wrong for that case.

The message is now rebuilt in the default method_missing handler (which has an Executor) for genuine undefined method errors:

  • class / module receiverclass <#name> / module <#name> (anonymous → the #<Class:0x…> form);
  • receiver with its own singleton class → its object string form (for #<Klass:0x…>);
  • ordinary objectan instance of <class #name>.

The rendering goes through #name only, never #inspect (a spec asserts #inspect is not called during message building). Visibility errors (private/protected method … called) keep their own message and are excluded via an undefined flag, so only real missing-method errors are re-rendered (and carry #args).

Testing

  • ruby/spec core/exception (minus kill-based files): 13 → 10 failures.
  • New differential tests: tests/no_method_error_message.rs (4, comparing against CRuby — named class/module/instance, nil/true/false/Integer receivers, the no-#inspect guarantee, and unchanged private/protected messages).
  • cargo test --lib --tests: green (a couple of transient LoadError/timeout flakes from concurrent build.rs reinstalls during local iteration, not from this change).

Remaining (out of scope here)

  • Exception#backtrace second-element/format details and backtrace-array identity (~7 specs) and top-level cause printing (2) — both need backtrace-representation work.
  • Signal-delivery-as-exception (Process.kill to self) — design decision in doc/signal_handling.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XpzdoFu46d2ChJpSzeWsNK


Generated by Claude Code

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

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.91667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.49%. Comparing base (dc59098) to head (c387a60).

Files with missing lines Patch % Lines
monoruby/src/builtins/object.rs 97.91% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sisshiki1969 sisshiki1969 merged commit 2423ce0 into master Jul 12, 2026
4 checks passed
@sisshiki1969 sisshiki1969 deleted the claude/cruby-4-0-2-specs-olt61c branch July 12, 2026 22:13
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.

2 participants