From: nobuyoshi nakada Date: 2005-12-20T16:33:46+09:00 Subject: [ruby-dev:28078] error message for super in aliased Kernel method なかだです。 [ruby-dev:28075]を書いていて気づいたんですが、aliasされた Kernelのメソッドでsuperを呼んだときのエラーメッセージが、1.8と 1.9で違っています。Kernel#fooがすでに呼ばれているわけで、1.9の 動作のほうが正しいように思えます。 $ ruby19 -e 'module Kernel; def foo; super; end; alias bar foo; end' -e bar -e:1:in `foo': super: no superclass method `foo' (NoMethodError) from -e:2 $ ruby18 -e 'module Kernel; def foo; super; end; alias bar foo; end' -e bar -e:1:in `bar': super: no superclass method `bar' (NoMethodError) from -e:2 また[ruby-dev:28076]の例も、SEGVにはなりませんがおかしなエラー になります。 $ ruby18 -v -e 'instance_eval "super"' ruby 1.8.4 (2005-12-20) [i386-cygwin] -e:1:in `instance_eval'-e:1: warning: too many arguments for format string : super: no superclass method `instance_eval' (NoMethodError) from -e:1 Index: eval.c =================================================================== RCS file: /cvs/ruby/src/ruby/eval.c,v retrieving revision 1.616.2.141 diff -U2 -p -r1.616.2.141 eval.c --- eval.c 16 Dec 2005 18:34:57 -0000 1.616.2.141 +++ eval.c 20 Dec 2005 07:29:29 -0000 @@ -6076,5 +6076,5 @@ rb_call_super(argc, argv) if (ruby_frame->last_class == 0) { rb_name_error(ruby_frame->last_func, "calling `super' from `%s' is prohibited", - rb_id2name(ruby_frame->last_func)); + rb_id2name(ruby_frame->orig_func)); } @@ -6082,5 +6082,5 @@ rb_call_super(argc, argv) klass = ruby_frame->last_class; if (RCLASS(klass)->super == 0) { - return method_missing(self, ruby_frame->last_func, argc, argv, CSTAT_SUPER); + return method_missing(self, ruby_frame->orig_func, argc, argv, CSTAT_SUPER); } @@ -6477,4 +6477,9 @@ eval_under_i(args) VALUE *args; { + struct FRAME *f = ruby_frame; + + if (f && (f = f->prev) && (f = f->prev)) { + ruby_frame = f; + } return eval(args[0], args[1], Qnil, (char*)args[2], (int)args[3]); } -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦