У меня проблемы с методом BUILD
в MooseX :: Declare . Если я скажу:
#!/usr/bin/perl
use MooseX::Declare;
class Foo {
has foo => (is => "rw", isa => "Str", default => "foo");
method BUILD {
print "I was called\n";
}
}
Foo->new;
Я получаю следующее менее полезное сообщение об ошибке:
Reference found where even-sized list expected at /Users/cowens/perl5/lib/perl5/MooseX/Method/Signatures/Meta/Method.pm line 335.
Validation failed for 'MooseX::Types::Structured::Tuple[MooseX::Types::Structured::Tuple[Object],MooseX::Types::Structured::Dict[]]' failed with value [ [ Foo=HASH(0x804b20) ], { HASH(0x8049e0) => undef } ], Internal Validation Error is: Validation failed for 'MooseX::Types::Structured::Dict[]' failed with value { HASH(0x8049e0) => undef } at /Users/cowens/perl5/lib/perl5/MooseX/Method/Signatures/Meta/Method.pm line 365
MooseX::Method::Signatures::Meta::Method::validate('MooseX::Method::Signatures::Meta::Method=HASH(0xb8aab0)', 'ARRAY(0xb8ab30)') called at /Users/cowens/perl5/lib/perl5/MooseX/Method/Signatures/Meta/Method.pm line 139
Foo::BUILD('Foo=HASH(0x804b20)', 'HASH(0x8049e0)') called at generated method (unknown origin) line 25
Foo::new('Foo') called at test.pl line 13
Но если я скажу:
#!/usr/bin/perl
use MooseX::Declare;
class Foo {
has foo => (is => "rw", isa => "Str", default => "foo");
sub BUILD {
my $self = shift;
print "I was called\n";
}
}
Foo->new;
все работает просто отлично (но уродливо и неуместно с остальным кодом).