From: "David A. Black" Date: 2008-10-11T03:14:57+09:00 Subject: [ruby-core:19288] Re: [Bug #632] StringIO has an odd alias implementation [?] Hi -- On Sat, 11 Oct 2008, Roger Pack wrote: > Bug #632: StringIO has an odd alias implementation [?] > http://redmine.ruby-lang.org/issues/show/632 > > Author: Roger Pack > Status: Open, Priority: Normal > > Here's my situation: > > require 'stringio' > class C < StringIO > alias :old_init :initialize > def initialize > old_init > end > end > C.new # fails 1.9, succeeds 1.8.6 > > normal classes: > > class A > def initialize > print 'A init' > end > end > class B < A > alias :old_init :initialize > def initialize > old_init > end > end > B.new # succeeds 1.9, 1.8 I believe it's because of this: static VALUE strio_initialize(int argc, VALUE *argv, VALUE self) { struct StringIO *ptr = check_strio(self); if (!ptr) { DATA_PTR(self) = ptr = strio_alloc(); } rb_call_super(0, 0); /* Specifically, this */ strio_init(argc, argv, ptr); return self; } Note that the error is coming from old_init: sio.rb:6:in `old_init': undefined method `old_init' for # (NoMethodError) So it's running strio_initialize under the name old_init and therefore unable to find a super version of it. David -- Rails training from David A. Black and Ruby Power and Light: Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL Advancing with Rails January 19-22 Fort Lauderdale, FL * * Co-taught with Patrick Ewing! See http://www.rubypal.com for details and updates!