diff options
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 31 |
1 files changed, 15 insertions, 16 deletions
@@ -1855,12 +1855,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; } @@ -1879,14 +1880,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; } @@ -3538,7 +3540,7 @@ rb_eval(self, n) recv = rb_eval(self, node->nd_recv); rval = node->nd_args->nd_head; - SETUP_ARGS0(node->nd_args->nd_next, node->nd_args->nd_alen-1,1); + SETUP_ARGS0(node->nd_args->nd_body, node->nd_args->nd_alen-1,1); val = rb_funcall3(recv, aref, argc, argv); switch (node->nd_mid) { case 0: /* OR */ @@ -3636,9 +3638,6 @@ rb_eval(self, n) rb_const_set(class_prefix(self, node->nd_else), node->nd_else->nd_mid, result); } else { - if (NIL_P(ruby_cbase)) { - rb_raise(rb_eTypeError, "no class/module to define constant"); - } rb_const_set(ruby_cbase, node->nd_vid, result); } break; |