Skip Menu |

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 70419
Status: resolved
Priority: 0/
Queue: Moose

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

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



Subject: Attribute parameterized trait cache warning
MooseX::Role::Parameterized's t/016-trait.t tickles this warning, but it's also pretty easy to reproduce outside of MXRP: $ perl -MCarp::Always -MMoose -E 'package R; use Moose::Role; package C; use Moose; has attr => (is => "ro", traits => [R => { foo => 1 }])' Roles with parameters cannot be cached. Consider applying the parameters before calling create_anon_class, or using 'weaken => 0' instead at /Users/sartak/.perl/perls/perl-5.14.1/lib/site_perl/5.14.1/darwin-2level/Moose/Meta/Class.pm line 145 Moose::Meta::Class::_anon_cache_key('Moose::Meta::Class', 'roles', 'ARRAY(0x100b75ca8)', 'weaken', '', 'superclasses', 'ARRAY(0x100b78210)') called at /Users/sartak/.perl/perls/perl-5.14.1/lib/site_perl/5.14.1/darwin-2level/Class/MOP/Package.pm line 109 Class::MOP::Package::create_anon('Moose::Meta::Class', 'superclasses', 'ARRAY(0x100b78210)', 'roles', 'ARRAY(0x100b75ca8)', 'cache', 1) called at /Users/sartak/.perl/perls/perl-5.14.1/lib/site_perl/5.14.1/darwin-2level/Class/MOP/Class.pm line 473 Class::MOP::Class::create_anon_class('Moose::Meta::Class', 'superclasses', 'ARRAY(0x100b78210)', 'roles', 'ARRAY(0x100b75ca8)', 'cache', 1) called at /Users/sartak/.perl/perls/perl-5.14.1/lib/site_perl/5.14.1/darwin-2level/Moose/Meta/Attribute.pm line 155 Moose::Meta::Attribute::interpolate_class('Moose::Meta::Attribute', 'HASH(0x100a85ed8)') called at /Users/sartak/.perl/perls/perl-5.14.1/lib/site_perl/5.14.1/darwin-2level/Moose/Meta/Attribute.pm line 112 Moose::Meta::Attribute::interpolate_class_and_new('Moose::Meta::Attribute', 'attr', 'definition_context', 'HASH(0x100985db8)', 'is', 'ro', 'traits', 'ARRAY(0x100827360)') called at /Users/sartak/.perl/perls/perl-5.14.1/lib/site_perl/5.14.1/darwin-2level/Moose/Meta/Class.pm line 704 Moose::Meta::Class::_process_new_attribute('Moose::Meta::Class=HASH(0x100b6d720)', 'attr', 'definition_context', 'HASH(0x100985db8)', 'is', 'ro', 'traits', 'ARRAY(0x100827360)') called at /Users/sartak/.perl/perls/perl-5.14.1/lib/site_perl/5.14.1/darwin-2level/Moose/Meta/Class.pm line 697 Moose::Meta::Class::_process_attribute('Moose::Meta::Class=HASH(0x100b6d720)', 'attr', 'definition_context', 'HASH(0x100985db8)', 'is', 'ro', 'traits', 'ARRAY(0x100827360)') called at /Users/sartak/.perl/perls/perl-5.14.1/lib/site_perl/5.14.1/darwin-2level/Moose/Meta/Class.pm line 566 Moose::Meta::Class::add_attribute('Moose::Meta::Class=HASH(0x100b6d720)', 'attr', 'definition_context', 'HASH(0x100985db8)', 'is', 'ro', 'traits', 'ARRAY(0x100827360)') called at /Users/sartak/.perl/perls/perl-5.14.1/lib/site_perl/5.14.1/darwin-2level/Moose.pm line 77 Moose::has('Moose::Meta::Class=HASH(0x100b6d720)', 'attr', 'is', 'ro', 'traits', 'ARRAY(0x100827360)') called at /Users/sartak/.perl/perls/perl-5.14.1/lib/site_perl/5.14.1/darwin-2level/Moose/Exporter.pm line 356 Moose::has('attr', 'is', 'ro', 'traits', 'ARRAY(0x100827360)') called at -e line 1 From IRC: <sartak> MooseX::Role::Parameterized's tests are exposing this weird warning caused by how attribute metaobjects + traits are created https://gist.github.com/1162952 <sartak> that's with Moose master <sartak> I'm thinking Moose::Meta::Attribute's interpolate_class needs to be a little smarter <doy> yeah, probably <doy> feel free to fix that too(: <confound> doy r helpful <sartak> to be fair I'm probably now the expert on interpolate_class just from being the only one to have looked at its code recently <doy> just find where those traits are being applied and don't pass cache => 1 if there are parameters in there other than -alias or -excludes <sartak> right <sartak> damnit. turns out it's not that simple since the method returns the class name. so the un-cached anonymous class metaobject goes out of scope pretty quickly <sartak> I'll file a bug and move on since it's just a warning . . . <sartak> I'll file a bug and move on and feel bad about it
Pushed topic/attribute_trait_parameters which includes a test for this behavior t/bugs/attribute_trait_parameters.t and a fix that makes this new test and MXRP's tests happy.