From: matz@... (Yukihiro Matsumoto) Date: 1999-11-08T14:31:59+09:00 Subject: [ruby-dev:8276] Re: super in eval まつもと ゆきひろです In message "[ruby-dev:8268] super in eval" on 99/11/08, Yasuhiro Fukuma writes: |ところで、これは仕様でしょうか? | | class A | def foo | p "foo" | end | def bar | p "bar" | end | def baz | p "baz" | end | end | | class B < A | def foo | super | end | def bar | eval "super" | end | def baz | binding | end | end | | obj = B.new | obj.foo #==> "foo" | obj.bar #==> superclass method `eval' disabled | b = obj.baz | eval("super", b) #==> superclass method `baz' disabled バグです。パッチをつけておきます。 --- eval.c 1999/11/08 03:57:00 1.15 +++ eval.c 1999/11/08 05:31:08 @@ -294,6 +294,11 @@ body = search_method(klass, mid, &origin); - if (!body || !body->nd_body || origin != klass) { + if (!body) { print_undef(klass, mid); + } + if (!body->nd_body) { + remove_method(klass, mid); + } + else { + body->nd_noex &= ~NOEX_UNDEF; } - body->nd_noex &= ~NOEX_UNDEF; } @@ -1698,3 +1703,3 @@ PUSH_FRAME(); - *ruby_frame = *_frame.prev; + *ruby_frame = *prev; ruby_frame->prev = prev; @@ -4367,3 +4372,3 @@ { - VALUE src, scope, vfile, vline; + VALUE src, scope, vfile, vline, val; char *file = "(eval)"; @@ -4381,2 +4386,15 @@ Check_SafeStr(src); + if (NIL_P(scope) && ruby_frame->prev) { + struct FRAME *prev; + VALUE val; + + prev = ruby_frame; + PUSH_FRAME(); + *ruby_frame = *prev->prev; + ruby_frame->prev = prev; + val = eval(self, src, scope, file, line); + POP_FRAME(); + + return val; + } return eval(self, src, scope, file, line); @@ -5474,2 +5492,3 @@ data->frame.last_func = ruby_frame->prev->last_func; + data->frame.last_class = ruby_frame->prev->last_class; }