From: Minero Aoki Date: 2002-05-06T12:17:27+09:00 Subject: [ruby-dev:17009] [PATCH] "unexpected return" for class C<1 あおきです。 以下のスクリプトを実行するとスーパークラスのところで unexpected return になります。 class C < 1 end パッチ添付。これでよければチェックインしときます。 ------------------------------------------------------------------- 青木峰郎 Mon May 6 12:12:55 2002 Minero Aoki * eval.c (superclass): undesirable "unexpected return" when the superclass is not a Class. Index: eval.c =================================================================== RCS file: /home/aamine/cvs/ruby/ruby/eval.c,v retrieving revision 1.289 diff -u -p -r1.289 eval.c --- eval.c 1 May 2002 09:41:49 -0000 1.289 +++ eval.c 6 May 2002 03:07:29 -0000 @@ -1445,7 +1445,6 @@ superclass(self, node) } POP_TAG(); if (state) { - superclass_error: switch (nd_type(node)) { case NODE_COLON2: rb_raise(rb_eTypeError, "undefined superclass `%s'", @@ -1458,7 +1457,10 @@ superclass(self, node) } JUMP_TAG(state); } - if (TYPE(val) != T_CLASS) goto superclass_error; + if (TYPE(val) != T_CLASS) { + rb_raise(rb_eTypeError, "superclass must be a Class but %s", + rb_class2name(CLASS_OF(val))); + } if (FL_TEST(val, FL_SINGLETON)) { rb_raise(rb_eTypeError, "can't make subclass of virtual class"); }