Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #39081] [BUG] (possible bug) multiple calls to __init for subclassed objects

7 views
Skip to first unread message

Patrick R . Michaud

unread,
May 5, 2006, 2:30:09 AM5/5/06
to bugs-bi...@rt.perl.org
# New Ticket Created by Patrick R. Michaud
# Please include the string: [perl #39081]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=39081 >


If a subclass doesn't define an "__init" method, then creating
a new instance of the subclass results in multiple calls to
the base class "__init" method.

I'm not sure if this is a real bug, or if the answer is
that "all class definitions must define an '__init'
method, even if that method is empty."

Here's a test program demonstrating the bug:

$ cat init2.pir
.sub main :main
$P0 = newclass 'Foo'
$P1 = subclass $P0, 'Bar'

$P2 = new 'Bar'
.end

.namespace [ 'Foo' ]

.sub '__init' :method
say "foo constructor"
.return ()
.end
$ ./parrot init2.pir
foo constructor
foo constructor
$

I've added a test for this to t/pmc/objects.t, feel free to
remove or otherwise adjust the test if this is in fact
correct behavior (and we should update the documentation if
this is the case).

Pm

Leopold Toetsch

unread,
May 10, 2006, 6:56:02 AM5/10/06
to perl6-i...@perl.org
Patrick R.Michaud (via RT) wrote:

> If a subclass doesn't define an "__init" method, then creating
> a new instance of the subclass results in multiple calls to
> the base class "__init" method.

Fixed, r12594. (__init was searched in parents with find_method, which
also searched parents ...)

> I've added a test for this to t/pmc/objects.t

Thanks, unTODOed.

> Pm

leo


0 new messages