[MacRuby-devel] Super not passing init: through to NSObject correctly?

Laurent Sansonetti lsansonetti at apple.com
Mon Oct 5 19:45:21 PDT 2009


Thanks for the report, I added your snippet in our test suite.

At a glance it looks like an infinite loop in the dispatcher.  
Definitely a bug :)

Laurent

On Oct 5, 2009, at 6:37 PM, Michael Shapiro wrote:

> Hi all,
> I searched a few months of the list archives and trac, but wasn't  
> able to find reference to this.
>
> Calling `super` inside of an overridden #init function where no ruby  
> ancestors define #init causes a segmentation fault. If I'm not  
> mistaken, shouldn't the init: message be passed to NSObject?
>
> ---------------------------------------------------------
> class HasInit
> def init
>  super
>  p 'HasInit'
>  self
> end
> end
>
> class A < HasInit; end
>
> class B < A; end
>
> A.new
> p 'A'
> B.new
> p 'B'
>
> class HasNoInit; end
>
> class C < HasNoInit; end
>
> class D < C
> def init
>  super
>  self
> end
> end
>
> C.new
> p 'C'
> D.new
> p 'D'
> ---------------------------------------------------------
>
> You should see the segfault happen when trying to init D, but  
> HasInit passes the message through to NSObject just fine, it seems.
>
> Tested with the 2009-10-05-1158 nightly.
>
> Thanks!
> --Mike
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel



More information about the MacRuby-devel mailing list