Skip Menu |
 

This queue is for tickets about the Clone CPAN distribution.

Report information
The Basics
Id: 67105
Status: resolved
Priority: 0/
Queue: Clone

People
Owner: Nobody in particular
Requestors: mp [...] leasingborsen.dk
Cc:
AdminCc:

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



Subject: Cloning of Moose object fails silently if the instance has been placed in a fieldhash
Download (untitled) / with headers
text/plain 755b
When cloning a Moose object, which have been placed in a fieldhash first, the cloning fails silently. The object is cloned, but all the attributes are empty. I've a attached a test program, which demonstrates this bug. In our setup, we get the following: # =[ Versions ]= # Clone v0.31 # Moose v1.24 # Hash::Util::FieldHash v1.04 ok 1 - Don't use a fieldhash before cloning Use of uninitialized value in string eq at clone.t line 42. not ok 2 - Using a fieldhash before cloning # Failed test 'Using a fieldhash before cloning' # at clone.t line 42. # bless({ somevar => "Test" }, "Foobar") != bless({}, "Foobar") 1..2 # Looks like you failed 1 test of 2. As Hash::Util::FieldHash is a native part of Perl, I've chosen to report the bug here first.
Subject: clone.t
Download clone.t
text/x-perl 1.2k
use strict; use warnings; use Test::More; use Test::Exception; use Data::Dump qw(pp); use Hash::Util::FieldHash 'fieldhash'; use Clone 'clone'; #============================================================================= # Declare a very simple package #============================================================================= { package Foobar; use Moose; has somevar => ( is => "rw", isa => "Str", ); 1; } #============================================================================= # Test clone #============================================================================= { fieldhash my %fh; note "=[ Versions ]=\n"; note "Clone v", $Clone::VERSION, "\n"; note "Moose v", $Moose::VERSION, "\n"; note "Hash::Util::FieldHash v", $Hash::Util::FieldHash::VERSION, "\n"; sub clonetest { my $use_fieldhash = shift; my $foo = Foobar->new(somevar => "Test"); $fh{$foo} = $foo if $use_fieldhash; my $bar = clone($foo); ok ( ($foo->somevar eq $bar->somevar), join '', ($use_fieldhash ? "Using " : "Don't use "), "a fieldhash before cloning" ) or diag(pp($foo), ' != ', pp($bar)); }; clonetest(0); clonetest(1); } done_testing;
Download (untitled) / with headers
text/plain 105b
I think the patch in https://rt.cpan.org/Ticket/Display.html?id=80201 should be able to solve this issue.
Download (untitled) / with headers
text/plain 304b
On Mon Oct 15 15:08:36 2012, GARU wrote: Show quoted text
> I think the patch in https://rt.cpan.org/Ticket/Display.html?id=80201 > should be able to solve this issue.
Indeed, the patch makes your test case pass. This is fixed in Clone 0.32, which has just been pushed to CPAN :) Thanks again for the bug report! breno


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.