Re: Moo, multiple-inheritance, unexpectedly uninitialized attributes

[email protected] (Kent Fredric) Fri, 27 Mar 2015 18:30:28 +1300
Newsgroups perl.moose
Message-ID <CAATnKFAhkGucBBvcryVS3HY0yvhSKTvAbOCdLCVMWHOMxeMFiQ@mail.gmail.com>
--089e01537a9623ca8705123e6e82
Content-Type: text/plain; charset=UTF-8

On 27 March 2015 at 11:23, Diab Jerius <[email protected]> wrote:

> I've translated some code using multiple inheritance to Moo, and am
> seeing some unexpected  behavior, namely that attributes inherited
> from the second parent class are not properly initialized.
>
> I've attached simplified versions of the pre- and post- Moo code.  The
> pre-Moo code generates this:
>
> $ perl tst1
> b1
> b2
>
> The Moo code outputs this:
>
> $ perl tst2
> b1
> Use of uninitialized value in say at tst2 line 30.
>
> In tst2, if I explicitly initialize the attribute from the second class:
>
>   my $q = C11->new( b2 => 'BBB' );
>
> It is still output as uninitialized.
>
> Would someone please point out what I'm missing?
>
> Thanks,
>
> Diab
>


Given the code works as expected when you s/Moo/Moose/, both in value
initialization, and in explicitly passing arguments to the second-inherited
module at construction time, I would agree that you have in fact found a
bug in Moo.

( Unless of course Moo has some documentation about explicitly not
supporting multiple inheritance )
-- 
Kent

*KENTNL* - https://metacpan.org/author/KENTNL

--089e01537a9623ca8705123e6e82
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On 27 March 2015 at 11:23, Diab Jerius <span dir=3D"ltr">&lt;<a href=3D=
"mailto:[email protected]" target=3D"_blank">[email protected]<=
/a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:=
0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I&#39;ve translated=
 some code using multiple inheritance to Moo, and am<br>
seeing some unexpected=C2=A0 behavior, namely that attributes inherited<br>
from the second parent class are not properly initialized.<br>
<br>
I&#39;ve attached simplified versions of the pre- and post- Moo code.=C2=A0=
 The<br>
pre-Moo code generates this:<br>
<br>
$ perl tst1<br>
b1<br>
b2<br>
<br>
The Moo code outputs this:<br>
<br>
$ perl tst2<br>
b1<br>
Use of uninitialized value in say at tst2 line 30.<br>
<br>
In tst2, if I explicitly initialize the attribute from the second class:<br=
>
<br>
=C2=A0 my $q =3D C11-&gt;new( b2 =3D&gt; &#39;BBB&#39; );<br>
<br>
It is still output as uninitialized.<br>
<br>
Would someone please point out what I&#39;m missing?<br>
<br>
Thanks,<br>
<br>
Diab<br>
</blockquote></div><br><br clear=3D"all"></div><div class=3D"gmail_extra">G=
iven the code works as expected when you s/Moo/Moose/, both in value initia=
lization, and in explicitly passing arguments to the second-inherited modul=
e at construction time, I would agree that you have in fact found a bug in =
Moo.<br><br></div><div class=3D"gmail_extra">( Unless of course Moo has som=
e documentation about explicitly not supporting multiple inheritance )<br><=
/div><div class=3D"gmail_extra">-- <br><div class=3D"gmail_signature"><div =
dir=3D"ltr"><div>Kent<font size=3D"1"><b> <br><br></b></font></div><div><sp=
an style=3D"color:rgb(204,204,204)"><font size=3D"1"><b>KENTNL</b> - <a hre=
f=3D"https://metacpan.org/author/KENTNL" target=3D"_blank">https://metacpan=
.org/author/KENTNL</a></font></span><br></div><div><br></div></div></div>
</div></div>

--089e01537a9623ca8705123e6e82--