Skip Menu |

This queue is for tickets about the Class-MethodMaker CPAN distribution.

Report information
The Basics
Id: 8798
Status: resolved
Priority: 0/
Queue: Class-MethodMaker

People
Owner: Nobody in particular
Requestors: tuck [...] whistlingfish.net
Cc:
AdminCc:

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



Subject: hash methods don't accept a hash reference
package: libclass-methodmaker-perl 2.02-1 (Debian) perl -v: This is perl, v5.8.4 built for i386-linux-thread-multi uname -a: Linux thoth 2.4.27-1-386 #1 Fri Sep 3 06:24:46 UTC 2004 i686 GNU/Linux Attempting to set a hash value using a hash reference instead of a list gives the error: Uneven number of arguments to method 'foo'. According to the documentation, this should work. This behavior makes it impossible to initialize hash values of objects during instantiation, as exhibited by the following: perl -e 'use Class::MethodMaker [ new => [qw(-hash new)], hash => ["foo"] ]; new main (foo => {})' Note that I've only tested this against v2.02-1, but I've manually checked the code in 2.04 and it doesn't seem to have been fixed.
From: tuck [...] whistlingfish.net
I've created a patch for my system, which I decided I may as well share with you.
--- components/hash.m.orig 2004-10-16 04:12:17.000000000 -0700 +++ components/hash.m 2004-12-09 05:15:15.000000000 -0800 @@ -180,6 +180,24 @@ +{}; } } + } elsif ( @_ == 2 and ref $_[1] eq 'HASH') { + %%STORE(+{%{$_[1]}},$v)%% + # Only asgn-check the potential *values* + %%ASGNCHK%(%%IFSTORE(values %$v, values %{$_[1]})%%)%% + if ( ! defined $want ) { + %{%%STORAGE%%} = %%IFSTORE(%$v,%{$_[1]})%%; + return; + } + + if ( $want ) { + (%{%%STORAGE%%} = %%IFSTORE(%$v,%{$_[1]})%%); + } else { + +{%{%%STORAGE%%} = %%IFSTORE(%$v,%{$_[1]})%%}; %%V2ONLY%% + %%V1COMPAT_ON%% + %{%%STORAGE%%} = %%IFSTORE(%$v,%{$_[1]})%%; + %%STORAGE%%; + %%V1COMPAT_OFF%% + } } else { croak "Uneven number of arguments to method '$names{'*'}'\n" unless @_ % 2;
Date: Sun, 13 Mar 2005 17:11:39 +0000
From: "Martyn J. Pearce" <fluffy [...] sixears.co.uk>
To: Guest via RT <bug-Class-MethodMaker [...] rt.cpan.org>
CC: undisclosed-recipients: ;
Subject: Re: [cpan #8798] hash methods don't accept a hash reference
RT-Send-Cc:
On Thu, Dec 09, 2004 at 08:34:17AM -0500, Guest via RT wrote: Show quoted text
> > This message about Class-MethodMaker was sent to you by guest <> via rt.cpan.org > > Full context and any attached attachments can be found at: > <URL: https://rt.cpan.org/Ticket/Display.html?id=8798 > > > I've created a patch for my system, which I decided I may as well share > with you.
Thank you Tuck. This patch has been integrated into 2.06. Your effort is much appreciated. Mx.