On Wed, 13 Oct 2010, Sir Robert Burbridge wrote:

I notice that the relevant bit of Moose::Object (line 39 from the error you 
got) says:
       28 sub BUILDARGS {
       29     my $class = shift;
       30     if ( scalar @_ == 1 ) {
       31         unless ( defined $_[0] && ref $_[0] eq 'HASH' ) {
       32             Class::MOP::class_of($class)->throw_error(
       33                 "Single parameters to new() must be a HASH ref",
       34                 data => $_[0] );
       35         }
       36         return { %{ $_[0] } };
       37     }
       38     else {
       39         return {...@_};
       40     }
       41 }

Based on that, it looks like some object is trying to instantiate with an odd 
number of args, but not just one arg.  Something like
      my $obj = My::Awesome::Moose::Class->new(a=>1, b=>2, 'c');

The check in line 30 checks if there was just one arg.  Probably, it should do 
something more like
      --- Object.old.pm    2010-10-13 11:03:48.000000000 -0400
      +++ Object.new.pm    2010-10-13 11:07:15.000000000 -0400
      @@ -35,9 +35,11 @@
               }
               return { %{ $_[0] } };
           }
      -    else {
      -        return {...@_};
      +    elsif (scalar @_ % 2) {
      +        warn "all args should be paired values (e.g. a=>1), not: @_";
           }
      +   
      +    return {...@_};
       }
       
       sub BUILDALL {

or maybe croak or something.

This seems like a reasonable idea. Would you mind discussing this on the Moose list ([email protected]) or in Moose IRC (irc://irc.perl.org/#moose). Or you can just send the patch to our RT queue, [email protected]


Thanks,

-dave

/*============================================================
http://VegGuide.org               http://blog.urth.org
Your guide to all that's veg      House Absolute(ly Pointless)
============================================================*/
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to