Hi,

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 trait which consumes another trait, and this seems
to be what's causing the problem.  Hopefully some (cut-down) code will
explain this...


package Test::Meta::Role::Trait::CoreObject;

use Moose::Role;

has primaryAttribute => (
    is => 'rw',
    isa => 'Str');

Moose::Exporter->setup_import_methods(
    with_caller => [ 'primaryKey' ],
    also => 'Moose::Role',
);

sub primaryKey {
    my $meta = shift;
    $meta = Moose::Meta::Role->initialize($meta) if !ref($meta);

    return $meta->primaryAttribute(@_);
}

no Moose::Role;

package Moose::Meta::Role::Custom::Trait::CoreObject;
sub register_implementation
{'Test::Meta::Role::Trait::CoreObject'};

1;


package Test::Meta::Role::Trait::LDAPObject;

use Moose::Role;

with 'Test::Meta::Role::Trait::CoreObject';

has oid => (
    is => 'rw',
    isa =>'Str',
);

Moose::Exporter->setup_import_methods(
    with_caller => [ 'oid', 'primaryKey' ],
    also => 'Moose::Role',
);

sub oid {
    my $meta = Moose::Meta::Role->initialize(shift);
    $meta->oid(shift);
}

no Moose::Role;

package Moose::Meta::Role::Custom::Trait::LDAPObject;
sub register_implementation
        {'Test::Meta::Role::Trait::LDAPObject'};

1;


package Test::TestRole;
use Test::Meta::Role::Trait::LDAPObject;
se Moose::Role -traits => 'LDAPObject';

oid '1.3.6.1.4.1.4247.1.747.99.23';

no Moose::Role;
1;


$ perl -Ilib -MTest::TestRole
String found where operator expected at lib/Test/TestRole.pm line 5, near "oid 
'1.3.6.1.4.1.4247.1.747.99.23'"
       (Do you need to predeclare oid?)
syntax error at lib/Test/TestRole.pm line 5, near "oid 
'1.3.6.1.4.1.4247.1.747.99.23'"
BEGIN not safe after errors--compilation aborted at lib/Test/TestRole.pm line 7.
Compilation failed in require.
BEGIN failed--compilation aborted.
$


The LDAPObject trait works fine when it doesn't consume the CoreObject
trait (and I remove primaryKey from setup_import_methods), so I
suspect we're using Moose::Exporter incorrectly, but I'm not too
familiar with this side of moose meta, in that I don't want to try and
jsut hack my way around it.  Any assistance would be greatly
appreciated.


Cheers
Toby Blake
School of Informatics
University of Edinburgh

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

Reply via email to