Subject: | parameterized metaclass trait creates a warning |
Date: | Wed, 19 Oct 2011 11:44:48 +0800 |
To: | bug-Moose [...] rt.cpan.org |
From: | Sherwin Daganato <sherwind [...] gmail.com> |
In Moose-2.0205, a bug that caused a warning when passing options to
an attribute trait has been fixed.
Should the same be done with metaclass trait?
This no longer creates a warning:
$ perl -MCarp::Always -MMoose -e 'package R; use Moose::Role; package
C; use Moose; has attr => (is => "ro", traits => [R => { foo => 1 }])'
But this one does:
$ perl -MCarp::Always -MMoose -e 'package R; use Moose::Role; package
C; use Moose -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/sherwind/perl5/lib/perl5/darwin-thread-multi-2level/Moose/Meta/Class.pm
line 145
Moose::Meta::Class::_anon_cache_key('Moose::Meta::Class', 'roles',
'ARRAY(0x8e17a4)', 'weaken', '', 'superclasses', 'ARRAY(0xa25c40)')
called at /Users/sherwind/perl5/lib/perl5/darwin-thread-multi-2level/Class/MOP/Package.pm
line 109
Class::MOP::Package::create_anon('Moose::Meta::Class',
'superclasses', 'ARRAY(0xa25c40)', 'roles', 'ARRAY(0x8e17a4)',
'cache', 1) called at
/Users/sherwind/perl5/lib/perl5/darwin-thread-multi-2level/Class/MOP/Class.pm
line 473
Class::MOP::Class::create_anon_class('Moose::Meta::Class',
'superclasses', 'ARRAY(0xa25c40)', 'roles', 'ARRAY(0x8e17a4)',
'cache', 1) called at
/Users/sherwind/perl5/lib/perl5/darwin-thread-multi-2level/Moose/Util/MetaRole.pm
line 134
Moose::Util::MetaRole::_make_new_class('Moose::Meta::Class',
'ARRAY(0x8e17a4)') called at
/Users/sherwind/perl5/lib/perl5/darwin-thread-multi-2level/Moose/Util/MetaRole.pm
line 79
Moose::Util::MetaRole::_make_new_metaclass('Moose::Meta::Class=HASH(0xa1fbe0)',
'HASH(0xa25be0)', 'class') called at
/Users/sherwind/perl5/lib/perl5/darwin-thread-multi-2level/Moose/Util/MetaRole.pm
line 28
Moose::Util::MetaRole::apply_metaroles('class_metaroles',
'HASH(0xa25be0)', 'for', 'C') called at
/Users/sherwind/perl5/lib/perl5/darwin-thread-multi-2level/Moose/Exporter.pm
line 523
Moose::Exporter::_apply_meta_traits('C', 'ARRAY(0xa2594c)') called at
/Users/sherwind/perl5/lib/perl5/darwin-thread-multi-2level/Moose/Exporter.pm
line 434
Moose::Exporter::__ANON__('Moose') called at -e line 1
C::BEGIN() called at -e line 1
eval {...} called at -e line 1