From: "Berger, Daniel" Date: 2007-12-11T07:43:55+09:00 Subject: Re: aliasing methods that don't exist > -----Original Message----- > From: Eric Hodel [mailto:drbrain@segment7.net] > Sent: Monday, December 10, 2007 3:28 PM > To: ruby-core@ruby-lang.org > Subject: aliasing methods that don't exist > > class X; alias_method :a, :a; end > class X; alias a a; end > > Is this a bug? Hehe, I'd say so. I'm pretty sure it's this line in eval.c/rb_alias causing it: if (name == def) return; I think this (untested) patch fixes it. Basically, it just moves the check until after verification that the method exists. >diff -u eval.orig eval.c --- eval.orig Sat Sep 22 17:01:50 2007 +++ eval.c Mon Dec 10 15:40:04 2007 @@ -2158,7 +2158,6 @@ VALUE singleton = 0; rb_frozen_class_p(klass); - if (name == def) return; if (klass == rb_cObject) { rb_secure(4); } @@ -2171,6 +2170,9 @@ if (!orig || !orig->nd_body) { print_undef(klass, def); } + + if (name == def) return; + if (FL_TEST(klass, FL_SINGLETON)) { singleton = rb_iv_get(klass, "__attached__"); } Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.