http://www.perlmonks.org?node_id=1017292


in reply to Moose type constraint failure

It works for me. The module:
use Modern::Perl; package Testing; use Bit::Vector; use Moose; has 'thing' => ( isa => 'Bit::Vector', is => 'rw', default => sub { return Bit::Vector->new(32); }, ); no Moose; __PACKAGE__->meta->make_immutable; 1;
And calling it:
use Modern::Perl; use Testing; use Data::Dump qw/dump/; my $object = Testing->new; say dump($object);
output:
bless({ thing => bless(do{\(my $o = 39557684)}, "Bit::Vector") }, "Tes +ting")
To reproduce your error, I have to initialize the object as follows:
my $object = Testing->new({thing => undef});

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics