From a9fcc99f45ee7d1cb6ac201e058564b675445faf Mon Sep 17 00:00:00 2001 From: Andrew Konchin Date: Wed, 18 Dec 2024 16:03:23 +0200 Subject: [PATCH] Fix NoMethodError#message when receiver is an instance of an anonymous class --- spec/tags/core/exception/no_method_error_tags.txt | 2 -- .../ruby/truffleruby/core/truffle/exception_operations.rb | 5 +---- 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 spec/tags/core/exception/no_method_error_tags.txt diff --git a/spec/tags/core/exception/no_method_error_tags.txt b/spec/tags/core/exception/no_method_error_tags.txt deleted file mode 100644 index 0a1d27b5d5d4..000000000000 --- a/spec/tags/core/exception/no_method_error_tags.txt +++ /dev/null @@ -1,2 +0,0 @@ -fails:NoMethodError#message uses class string representation when receiver is an instance of anonymous class -fails:NoMethodError#message does not call #inspect when calling Exception#message diff --git a/src/main/ruby/truffleruby/core/truffle/exception_operations.rb b/src/main/ruby/truffleruby/core/truffle/exception_operations.rb index 8a4513f1769d..05cbef28e16d 100644 --- a/src/main/ruby/truffleruby/core/truffle/exception_operations.rb +++ b/src/main/ruby/truffleruby/core/truffle/exception_operations.rb @@ -87,10 +87,7 @@ def self.receiver_string(receiver) "module #{receiver}" else klass = Primitive.metaclass(receiver) - if klass.name - "an instance of #{klass.name}" - end - # else fall through to rb_any_to_s + "an instance of #{klass}" end rescue Exception # rubocop:disable Lint/RescueException nil