On Fri, Jul 08, 2011 at 04:50:39PM -0300, Marcos Barbeitos wrote:
> Howdy,
>
> New to Moose, ran into something curious. Somewhere in the application I
> got:
>
>
> package Constants;
>
> use constant TRUE => 1;
> use constant FALSE => 0;
>
>
> I know, I've read several postings of people grumbling that 1 in Perl means
> true and 0 means false and to just get over it. However, somewhere else I
> got:
>
>
> package Roles::Tuple;
>
> use Moose::Role;
> use Constants;
> use Check;
>
>
> and:
>
>
> package Roles::Schema;
>
> use Moose::Role;
> use Constants
> use Check;
>
>
> and then I have:
>
>
> package Tuple;
>
> use Moose;
> with 'Roles::Tuple', 'Roles::Schema';
>
>
> If I try 'use Tuple' I get:
>
> 'Due to method name conflicts in roles 'Roles::Schema' and 'Roles::Tuple',
> the methods 'FALSE' and 'TRUE' must be implemented or excluded by 'Tuple''
>
> Both 'Constants' and 'Check', which are used by 'Roles::Schema' and
> 'Roles::Tuple' also export several other variables and subroutines, but I
> only run into problems with the constants TRUE and FALSE.
>
> Any help will be greatly appreciated. Cheers!
I think this is actually a bug in our method detection heuristics - perl
optimized constants to not be "real" subroutines, and so they don't
track information about their definition in the same way other
subroutines do. I'll see if I can come up with a fix. In the meantime,
you can work around this issue by adding "__PACKAGE__->can('TRUE');
__PACKAGE__->can('FALSE')" to Constants.pm - this should prevent them
from being "actual" constants, and so Moose should be able to deal with
them properly.
-doy