Subject: | use overload does not work |
Hello. Thanks for great distribution and all your efforts!
"use overload" does not work with MooseX::Declare, but works with Moose.
MooseX::Declare version 0.27
Moose version 0.89
perl, v5.10.0 built for i686-linux-thread-multi
tested on two different linux 2.6 boxes
minimal test case:
======================
Aaa.pm:
======================
use MooseX::Declare;
class Aaa {
has Value => ( is => 'rw', isa => 'Str' );
method asString
{
return $self->Value;
}
use overload '""' => sub { $_[ 0 ]->asString };
}
======================
Bbb.pm
======================
package Bbb;
use Moose;
use MooseX::Method::Signatures;
has Value => ( is => 'rw', isa => 'Str' );
method asString
{
return $self->Value;
}
use overload '""' => sub { $_[ 0 ]->asString };
1;
======================
test.pl
======================
use strict;
use warnings;
use Aaa;
use Bbb;
my $a = Aaa->new( Value => 'test' );
my $b = Bbb->new( Value => 'test' );
print "$a\n";
print "$b\n";
Here the first output line returns Aaa=HASH(0x8935760) and the second
line returns 'test' as expected.
If you add "package Aaa;" to the head of Aaa.pm everything is fine.