I am having difficulty with the BUILD
method in MooseX::Declare. If I say:
#!/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;
I get the following less than helpful error message:
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
But if I say:
#!/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;
everything works just fine (but is ugly and out of place with the rest of the code).