Skip Menu |

This queue is for tickets about the Moo CPAN distribution.

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

People
Owner: Nobody in particular
Requestors: ilmari.ikonen84 [...] gmail.com
Cc:
AdminCc:

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



Subject: Moo::ification fails with Moose roles
Date: Wed, 24 Dec 2014 10:42:00 +0200
To: bug-Moo [...] rt.cpan.org
From: Ilmari Ikonen <ilmari.ikonen84 [...] gmail.com>
I am using Moo-1.006001 in Perl 5.20.1. The following code fails with a long stack trace related to Moo::ification: package A; use Moose::Role; sub consumers { #The line that causes the problem: __PACKAGE__->meta->consumers(); } 1; package B; use Moose; with qw(A); 1; package ::main; use B; #I picked up Kavorka, but got the same crash with DBIx::Class and Web::Simple at least. #Without this, it works fine. use Kavorka; B->consumers(); 1;
CC: undisclosed-recipients:;
Subject: Re: [rt.cpan.org #101111] Moo::ification fails with Moose roles
Date: Thu, 25 Dec 2014 23:13:31 +0100
To: bug-Moo [...] rt.cpan.org
From: ilmari [...] ilmari.org (Dagfinn Ilmari Mannsåker)

Message body is not shown because it is too large.

CC: undisclosed-recipients:;
Subject: Re: [rt.cpan.org #101111] Moo::ification fails with Moose roles
Date: Fri, 26 Dec 2014 01:18:51 +0100
To: bug-Moo [...] rt.cpan.org
From: ilmari [...] ilmari.org (Dagfinn Ilmari Mannsåker)
""(Dagfinn Ilmari Mannsåker)" via RT" <bug-Moo@rt.cpan.org> writes: Show quoted text
> Queue: Moo > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=101111 > > > "Ilmari Ikonen via RT" <bug-Moo@rt.cpan.org> writes: >
>> I am using Moo-1.006001 in Perl 5.20.1. The following code fails with >> a long stack trace related to Moo::ification:
> > Thanks for reporting this. Here's a minimal case that reproduces what I > can only guess (since you didn't include the error output) is the error: > > { package RA; use Moose::Role; } > { package CA; use Moose; } > { package CB; use Moo; extends 'CA'; } > > RA->meta->consumers; > > Note that no class needs to consume the role, but the Moo class needs to > extend a Moose class.
Even more minimally: require Method::Generate::Constructor; require Moo::HandleMoose; Moo::HandleMoose::inject_real_metaclass_for('Method::Generate::Constructor'); This is because Method::Generate::Constructor has manually defined accessor methods for the attributes before doing 'use Moo'. This causes Moo to not consider them method, so the local @{_getstash($name)}{keys %methods}; in Moo::HandleMoose::inject_real_metaclass_for() fails to hide them from Moose::Meta::Attribute::_process_accessors(). One possible fix would be to delete the accessors from the not_methods list at the end of bootstrapping Method::Generate::Constructor: diff --git a/lib/Method/Generate/Constructor.pm b/lib/Method/Generate/Constructor.pm index 6828357..a8046bd 100644 --- a/lib/Method/Generate/Constructor.pm +++ b/lib/Method/Generate/Constructor.pm @@ -205,8 +205,7 @@ sub new { my $class = shift; bless $class->BUILDARGS(@_), $class; } -Moo->_constructor_maker_for(__PACKAGE__) -->register_attribute_specs( +my %attr = ( attribute_specs => { is => 'ro', reader => 'all_attribute_specs', @@ -217,5 +216,12 @@ Moo->_constructor_maker_for(__PACKAGE__) subconstructor_handler => { is => 'ro' }, package => { is => 'bare' }, ); +Moo->_constructor_maker_for(__PACKAGE__) +->register_attribute_specs(%attr); +for my $name (keys %attr) { + if (my $meth = __PACKAGE__->can($attr{$name}{reader}||$name)) { + delete ${$Moo::MAKERS{+__PACKAGE__}{not_methods}}{$meth}; + } +} 1; -- "I use RMS as a guide in the same way that a boat captain would use a lighthouse. It's good to know where it is, but you generally don't want to find yourself in the same spot." - Tollef Fog Heen
This has been fixed in git, and will be included in the next release. Thanks for the report.
Fixed in 1.007000