Subject: | Set::Object loses overload status |
If you insert an object which has the OVERLOAD SV flag set, then when it
comes out, that flag is lost.
This is because the internal bucket structure used by the module only
stores a reference to the stored SV, however the overload flag is stored
in the RV that points to the SV.
I am unsure if the OVERLOAD flag is the only flag affected by this bug.
Here is a test script:
#!/usr/bin/perl -w
use strict;
use Set::Object;
require 't/Person.pm';
use Devel::Peek;
print "1..1\n";
my $person = new Person( firstname => "Montgomery", name => "Burns" );
my $person2 = \$person;
my $person3 = \$person;
my $set = Set::Object->new($person);
my ($newperson) = $set->members();
if ($newperson ne "Montgomery Burns") {
print "Arse: put in:\n";
print Dump($person);
print "Got out:\n";
print Dump($newperson);
print "not ";
}
print "ok 1\n";
Which requires this addition to t/Person.pm in the 1.02 distribution:
use overload
'""' => \&stringify,
'==' => \&equals,
fallback => 1;
sub stringify
{
my $self = shift;
return "$self->{firstname} $self->{name}";
}
sub equals
{
my $a = shift;
my $b = shift;
return ( $a->{firstname} eq $b->{firstname} &&
$a->{name} eq $b->{name} )
}
(The "equals" function is for another test script, which still fails,
for the same reason).