Skip Menu |

This queue is for tickets about the Set-Object CPAN distribution.

Report information
The Basics
Id: 621
Status: resolved
Worked: 1.1 hours (69 min)
Priority: 0/
Queue: Set-Object

People
Owner: SAMV [...] cpan.org
Requestors: SAMV [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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).
I don't know, what's the world coming to when a user has to fix his own bugs. Where's the service around here? :-)
diff -uNr Set-Object-1.02.orig/Changes Set-Object-1.02/Changes --- Set-Object-1.02.orig/Changes Tue May 9 08:55:07 2000 +++ Set-Object-1.02/Changes Sat Jan 25 01:07:48 2003 @@ -17,3 +17,5 @@ 1.02 8 May 08 2000 - fixed bug that miscomputed new bucket while reindexing +1.03 24 Jan 2003 + - fixed overload related bug diff -uNr Set-Object-1.02.orig/MANIFEST Set-Object-1.02/MANIFEST --- Set-Object-1.02.orig/MANIFEST Tue Nov 9 17:13:12 1999 +++ Set-Object-1.02/MANIFEST Sat Jan 25 01:08:05 2003 @@ -7,11 +7,13 @@ t/equal.t t/clear.t t/difference.t +t/flags.t t/includes.t t/insert.t t/intersection.t t/members.t t/Person.pm +t/Saint.pm t/refcount.t t/remove.t t/subsuper.t diff -uNr Set-Object-1.02.orig/Object.pm Set-Object-1.02/Object.pm --- Set-Object-1.02.orig/Object.pm Tue May 9 08:55:25 2000 +++ Set-Object-1.02/Object.pm Sat Jan 25 01:08:28 2003 @@ -181,7 +181,7 @@ @EXPORT = qw( ); -$VERSION = '1.02'; +$VERSION = '1.03'; bootstrap Set::Object $VERSION; diff -uNr Set-Object-1.02.orig/Object.xs Set-Object-1.02/Object.xs --- Set-Object-1.02.orig/Object.xs Tue May 9 08:53:56 2000 +++ Set-Object-1.02/Object.xs Sat Jan 25 01:09:29 2003 @@ -395,6 +395,7 @@ if (*el_iter) { SV* el = newRV(*el_iter); + sv_bless(el, SvSTASH(*el_iter)); sv_2mortal(el); PUSHs(el); } diff -uNr Set-Object-1.02.orig/t/Saint.pm Set-Object-1.02/t/Saint.pm --- Set-Object-1.02.orig/t/Saint.pm Thu Jan 1 12:00:00 1970 +++ Set-Object-1.02/t/Saint.pm Sat Jan 25 01:09:36 2003 @@ -0,0 +1,17 @@ +package Saint; + +# `empty subclass' test + +use vars qw(@ISA); + +@ISA = qw(Person); + +sub stringify { + + my $self = shift; + + return "Saint $self->{firstname} $self->{name}"; + +} + +1; diff -uNr Set-Object-1.02.orig/t/flags.t Set-Object-1.02/t/flags.t --- Set-Object-1.02.orig/t/flags.t Thu Jan 1 12:00:00 1970 +++ Set-Object-1.02/t/flags.t Sat Jan 25 01:09:44 2003 @@ -0,0 +1,39 @@ +#!/usr/bin/perl -w +# +# check that objects retain things like overloading after going in +# and out of Set::Object containers +# + +use strict; + +use Set::Object; + +require 't/Person.pm'; +require 't/Saint.pm'; + +print "1..2\n"; + +my $person = new Person( firstname => "Montgomery", name => "Burns" ); + +my $set = Set::Object->new($person); + +my ($newperson) = $set->members(); + +if ($newperson ne "Montgomery Burns") { + print "not "; +} +print "ok 1\n"; + +my $saint = Saint->new( firstname => "Timothy", name => "Leary" ); + +$set = Set::Object->new($saint); + +my ($newsaint) = $set->members(); + +if ($newsaint ne "Saint Timothy Leary") { + print "not "; +} + +print "ok 2\n"; + +