summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-02 03:00:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-02 03:00:23 +0000
commit83740fa4bda976d6aef50a452a9dd433b5446af1 (patch)
tree69c889559913cdd75cca9d04a906c49e6e79ef39 /variable.c
parent18ef8f10782e202f1605ff2d3d59241f62989b67 (diff)
* variable.c (rb_const_defined_0): look up constants in Object as
well. [ruby-dev:21458] * test/ruby/test_defined.rb (TestDefined::test_defined): test for constants. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/variable.c b/variable.c
index 05f6281..32616fc 100644
--- a/variable.c
+++ b/variable.c
@@ -1430,12 +1430,12 @@ rb_const_defined_0(klass, id, exclude, recurse)
ID id;
int exclude, recurse;
{
- VALUE tmp = klass, value;
+ VALUE value, tmp;
+ int mod_retry = 0;
+ tmp = klass;
+ retry:
while (tmp) {
- if (tmp == rb_cObject && klass != rb_cObject) {
- break;
- }
if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl, id, &value)) {
if (value == Qundef && NIL_P(autoload_file(klass, id)))
return Qfalse;
@@ -1444,8 +1444,10 @@ rb_const_defined_0(klass, id, exclude, recurse)
if (!recurse && klass != rb_cObject) break;
tmp = RCLASS(tmp)->super;
}
- if (!exclude && BUILTIN_TYPE(klass) == T_MODULE) {
- return rb_const_defined(rb_cObject, id);
+ if (!exclude && !mod_retry && BUILTIN_TYPE(klass) == T_MODULE) {
+ mod_retry = 1;
+ tmp = rb_cObject;
+ goto retry;
}
return Qfalse;
}