summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/variable.c b/variable.c
index 24e66a6b56..ef4b49e60d 100644
--- a/variable.c
+++ b/variable.c
@@ -967,11 +967,16 @@ rb_const_defined(klass, id)
VALUE klass;
ID id;
{
- while (klass) {
- if (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, id, 0)) {
+ VALUE tmp = klass;
+
+ while (tmp) {
+ if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,0)) {
return TRUE;
}
- klass = RCLASS(klass)->super;
+ tmp = RCLASS(tmp)->super;
+ }
+ if (BUILTIN_TYPE(klass) == T_MODULE) {
+ return rb_const_defined(cObject, id);
}
if (st_lookup(class_tbl, id, 0))
return TRUE;