Subject: | problem with role trait which consumes another role trait |
Date: | Tue, 23 Aug 2016 10:45:17 +0100 (BST) |
To: | bug-Moose [...] rt.cpan.org |
From: | Toby Blake <toby [...] inf.ed.ac.uk> |
Hi,
I *think* this is a bug in Moose, or more likely, Moose::Exporter.
I posted a message similar to this, to the Moose mailing list (just in
case this looks familiar)...
We have a bit of code which has broken between 2.1005 and 2.1804 - it
was originally written somewhere around 0.85 and I don't think has
really changed much since then.
The code involves a role trait which consumes another role trait, and
this seems to be what's causing the problem. Hopefully some
simple code will explain this...
package Test::Meta::Role::Trait::Trait1;
use Moose::Role;
Moose::Exporter->setup_import_methods(
with_meta => [ 'trait1sub' ],
also => 'Moose::Role',
);
sub trait1sub {
my $meta = shift;
print "trait1sub\n";
}
no Moose::Role;
package Moose::Meta::Role::Custom::Trait::Trait1;
sub register_implementation
{'Test::Meta::Role::Trait::Trait1'};
1;
package Test::Meta::Role::Trait::Trait2;
use Moose::Role;
with 'Test::Meta::Role::Trait::Trait1';
Moose::Exporter->setup_import_methods(
with_meta => [ 'trait2sub', 'trait1sub' ],
also => 'Moose::Role',
);
sub trait2sub {
my $meta = shift;
print "trait2sub\n";
}
no Moose::Role;
package Moose::Meta::Role::Custom::Trait::Trait2;
sub register_implementation
{'Test::Meta::Role::Trait::Trait2'};
1;
package Test::TestRole;
use Test::Meta::Role::Trait::Trait2;
use Moose::Role -traits => 'Trait2';
trait1sub;
trait2sub;
no Moose::Role;
1;
This works fine with moose-2.1005:
[mambo]toby: perl -Ilib -MTest::TestRole
trait1sub
trait2sub
^C
[mambo]toby:
... but not with moose-2.1804:
[bolt]toby: perl -Ilib -MTest::TestRole
Bareword "trait2sub" not allowed while "strict subs" in use at lib/Test/TestRole.pm line 7.
Compilation failed in require.
BEGIN failed--compilation aborted.
[bolt]toby:
Thanks,
Toby Blake
School of Informatics
University of Edinburgh
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.