From ccf3fff6edb47ecb1298e7cdca6b619af136f51a Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 26 Dec 2005 08:18:33 +0000 Subject: * eval.c (ev_const_get): fixed a bug in constant reference during instance_eval. [yarv-dev:707] * eval.c (ev_const_defined): ditto. * lib/yaml.rb (YAML::add_domain_type): typo fixed. a patch from Joel VanderWerf . [ruby-talk:165285] [ruby-core:6995] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- eval.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'eval.c') diff --git a/eval.c b/eval.c index 82a2527148..719860a474 100644 --- a/eval.c +++ b/eval.c @@ -1810,12 +1810,13 @@ ev_const_defined(cref, id, self) while (cbase && cbase->nd_next) { struct RClass *klass = RCLASS(cbase->nd_clss); - if (NIL_P(klass)) return rb_const_defined(CLASS_OF(self), id); - if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, &result)) { - if (result == Qundef && NIL_P(rb_autoload_p((VALUE)klass, id))) { - return Qfalse; + if (!NIL_P(klass)) { + if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, &result)) { + if (result == Qundef && NIL_P(rb_autoload_p((VALUE)klass, id))) { + return Qfalse; + } + return Qtrue; } - return Qtrue; } cbase = cbase->nd_next; } @@ -1834,13 +1835,15 @@ ev_const_get(cref, id, self) while (cbase && cbase->nd_next) { VALUE klass = cbase->nd_clss; - if (NIL_P(klass)) return rb_const_get(CLASS_OF(self), id); - while (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, id, &result)) { - if (result == Qundef) { - if (!RTEST(rb_autoload_load(klass, id))) break; - continue; + if (!NIL_P(klass)) { + while (RCLASS(klass)->iv_tbl && + st_lookup(RCLASS(klass)->iv_tbl, id, &result)) { + if (result == Qundef) { + if (!RTEST(rb_autoload_load(klass, id))) break; + continue; + } + return result; } - return result; } cbase = cbase->nd_next; } -- cgit v1.2.3