Subject: | Default attribute values break when inheriting from Pod::Parser |
I haven't had time to debug this, but I do have a simple test case.
Consider the following code:
#!/usr/bin/env perl
{
package MyBase;
sub foo { 1 }
}
{
package One;
use Moose;
extends qw{MyBase Moose::Object};
has counter => ( is => 'rw', isa => 'Int', default => 1 );
sub inc_counter {
my $self = shift;
$self->counter( $self->counter + 1 );
}
}
my $one = One->new;
$one->inc_counter;
print $one->counter, $/;
The prints '2', as expected. However, if the extends line is changed to
inherit from Pod::Parser, we no longer have a default value:
extends qw{Pod::Parser Moose::Object};
Running the code now produces this:
Use of uninitialized value in addition (+) at inherit.pl line 19.
1
I've worked around this by providing a BUILD method which sets the
defaults, but I'm curious to know if I've done something wrong or if
this is a bug in Moose (if it's not a bug, it's definitely
counter-intuitive).
Cheers,
Ovid