Skip Menu |

This queue is for tickets about the Moo CPAN distribution.

Report information
The Basics
Id: 64906
Status: resolved
Priority: 0/
Queue: Moo

People
Owner: Nobody in particular
Requestors: djerius [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.009005
Fixed in: (no value)



Subject: Role::Tiny::_load_module is easily misled about modules being loaded
All tests w/ Perl 5.10.0, Moo 0.00905 Role::Tiny::_load_module uses $class->can('can') to see if $class is loaded. Unfortunately, this can be (easily) misled. The first instance of this I came across involved the class which was requesting a role also using Class::Autouse ==> Foo.pm <== package Foo; use Moo; use Class::Autouse qw[ :nostat Bar ]; with 'Roll'; 1; ==> Roll.pm <== package Roll; use Moo::Role; 1; % perl Foo.pm Roll is not a Role::Tiny at /proj/axaf/ots/pkgs/perl/x86_64-linux_debian-5.0/lib/perl5/Role/Tiny.pm line 57. Class::Autouse plugs in a can() method which foils the can('can') check by returning a valid coderef. The next example is a little strange. If you use a class which has a component in its name which is the same as your role class Perl will happily return a coderef from can('can'). For example: ==> Gak.pm <== package Roll::Mine; 1; package Gak; use Moo; with 'Roll'; % perl Gak.pm Roll is not a Role::Tiny at /proj/axaf/ots/pkgs/perl/x86_64-linux_debian-5.0/lib/perl5/Role/Tiny.pm line 57. Removing the Roll::Mine package causes it to work properly. Thanks, Diab
On Tue Jan 18 18:38:31 2011, DJERIUS wrote: Show quoted text
> All tests w/ Perl 5.10.0, Moo 0.00905 > > Role::Tiny::_load_module uses $class->can('can') to see if $class is > loaded. Unfortunately, this can be (easily) misled.
This has been rewritten twice since and should now be not broken. Please re-open if I'm wrong.