Subject: | Native Types providing _default_default (ie: String ) don't work with lazy_build |
Any native trait with _default_default will populate the attributes
'default' field in the absence of one. In the case of people using
'lazy_build' instead of default => , this results in a moose failure.
A not very obvious to explain failure at that. ( Had to randomly comment
out lines to try work out what was causing it :/ )
# died: You can not use lazy_build and default for the same attribute
(myattr) at
/usr/lib64/perl5/vendor_perl/5.12.1/x86_64-linux-thread-multi/Class/MOP/Method/Wrapped.pm
line 48
Attached is a Test::Exception + Test::More test that should report when
this feature returns to working =).
Subject: | stringtrait.pl |
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 1;
use Test::Exception;
lives_ok( sub {
eval <<'EOF' or die; }, 'Lazy_build + Native Traits work ' );
package Example;
use Moose;
has myotherattr => (
is => 'rw',
isa => 'Str',
);
has myattr => ( # Eval Line 10
is => 'rw',
lazy_build => 1, # This
isa => 'Str',
traits => ['String'], # Plus This == FAIL.
handles => { append_myattr => 'append' }
);
sub _build_myattr {
my $self = shift;
return $self->myootherattr . "<< Implicit";
}
1;
EOF