Skip to content

Commit 76701eb

Browse files
author
Yorick Peterse
committedApr 21, 2015
Don't use Object#inspect in Kernel#method
As discussed already in #3373 some people might overwrite this in a way that's not compatible with the default behaviour. While we can't (and are not going to) guard ourselves against every possible case where somebody might've overwritten a core Ruby method, we _can_ at least in this particular case remove the dependency on Object#inspect. As an aside this now ensures that our error messages are the same as MRI's, although one could argue that this is a bit odd: class Foo end Foo.method(:bar) # => NameError: undefined method `barr' for class `Class' Instead of: Foo.method(:bar) # => NameError: undefined method `barr' for class `Foo'
1 parent 0ec0c5c commit 76701eb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

Diff for: ‎kernel/common/kernel.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ def method(name)
524524
elsif respond_to_missing?(name, true)
525525
Method.new(self, self.class, Rubinius::MissingMethod.new(self, name), name)
526526
else
527-
raise NameError, "undefined method `#{name}' for #{self.inspect}"
527+
raise NameError, "undefined method `#{name}' for class #{self.class}"
528528
end
529529
end
530530

0 commit comments

Comments
 (0)