aboutsummaryrefslogtreecommitdiffstats
path: root/proc.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2023-06-22 09:44:51 -0700
committerJeremy Evans <code@jeremyevans.net>2023-07-26 07:27:15 -0700
commit786a864900ceee6ed89d7df81698bbbe7e7bd6ae (patch)
treeeec3826a102ced34b8e158faa3b48a169124b8da /proc.c
parent9b405a18bea7825cba794e42a1fef58a48451ec3 (diff)
downloadruby-786a864900ceee6ed89d7df81698bbbe7e7bd6ae.tar.gz
Make {Nil,True,False}Class#singleton_method always raise NameError
{Nil,True,False}Class#singleton_methods always returns [] indicating that there are no singleton methods defined, so #singleton_method should be consistent with that. Fixes [Bug #11064]
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/proc.c b/proc.c
index c284d4fcab..9fd24a8fd4 100644
--- a/proc.c
+++ b/proc.c
@@ -2096,10 +2096,9 @@ rb_obj_singleton_method(VALUE obj, VALUE vid)
VALUE klass = rb_singleton_class_get(obj);
ID id = rb_check_id(&vid);
- if (NIL_P(klass)) {
- /* goto undef; */
- }
- else if (NIL_P(klass = RCLASS_ORIGIN(klass))) {
+ if (NIL_P(klass) ||
+ NIL_P(klass = RCLASS_ORIGIN(klass)) ||
+ !NIL_P(rb_special_singleton_class(obj))) {
/* goto undef; */
}
else if (! id) {