summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-08 08:12:39 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-08 08:12:39 +0000
commit8673eacafa039f056927e0f91ce195afae9b9019 (patch)
treead28cdccaa2ee114d3cf523de4d9f9d0167b2d50 /variable.c
parent9c855a83f2c34ecf0e2f448d2213a6b091cdce95 (diff)
local_variables/defined?(TOPLEVEL_CONST) in modules
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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;