Skip Menu |

This queue is for tickets about the Moo CPAN distribution.

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

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

Bug Information
Severity: (no value)
Broken in: 1.001000
Fixed in: 1.002000



Subject: Moo::Object->meta->can() dies.
I was just doing bulk introspecting of various things, and in doing so, tried to introspect "Moo::Object"

in the general case this logic is fine:
sub example {
     my ($class) = shift;
     return unless if $class->can('meta');
     return unless $class->meta->can("somethinghere");
     ....
}

However, when $class happens to be "Moo::Object", the usually safe approach of calling "can" explodes in your face.

Instead, calling "can" results in:
Can't call method "all_attribute_specs" on an undefined value at .../Moo/HandleMoose.pm line 70

Relevant backtrace lines are: 

Moo::HandleMoose::inject_real_metaclass_for('Moo::Object') called at Moo/HandleMoose/FakeMetaClass.pm line 12
Moo::HandleMoose::FakeMetaClass::can('Moo::HandleMoose::FakeMetaClass=HASH(0x1141ff8)') called at /tmp/moofail.pl line 12

And equivalent test attached.
Subject: moofail.pl
#!/usr/bin/env perl use strict; use warnings; use utf8; use Test::More; use Test::Fatal; use Moo::Object; ok( Moo::Object->can('meta'), 'Moo::Object can meta'); is( exception { Moo::Object->meta->can() } , undef, "Moo::Object->meta->can doesn't explode" ); done_testing;

ok, progress made, tests and a proposed solution in gitmo  kentnl/meta-can-fail

Test patch: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo/Moo.git;a=commitdiff;h=1bc4b89be43066fb21ff89d9650f3821f8072e32

Proposed solution that seems to be the best solution so far : http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo/Moo.git;a=commitdiff;h=cafdfdf50113af01a5101300565437a35df8c4a2

Fixed in Moo 1.002000