Skip Menu |

This queue is for tickets about the Moo CPAN distribution.

Report information
The Basics
Id: 83732
Status: resolved
Priority: 0/
Queue: Moo

People
Owner: Nobody in particular
Requestors: MJD [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.000008
Fixed in: 1.003001



Subject: Bad arguments to 'has' are not diagnosed
My input file included: has data => ( is => 'rw', isa => sub { reftype $_[0] eq "ARRAY" }. init_arg => undef, lazy => 1, builder => '_build_data', ); which caused Moo to crash with the unhelpful error message: Use of uninitialized value within @_ in list assignment at /usr/local/lib/perl5/site_perl/5.12.3/Moo.pm line 40. The problem is that the "isa" line ends with a period instead of a comma, but this shouldn't cause Moo to crash.
Can you clarify what part of the error you take issue with? There are two sides to this issue. First is the direct issue of providing parameters that can't be put into a hash. This has been improved some in newer perls, as the error 'Odd number of elements in hash assignment' better reflects the issue. This could still probably be improved using Carp instead of relying on the fatal warning. In general though, Moo mainly encourages people to use tools like Carp::Always to track the source of errors instead of handling them on its own. The second part is that Moo doesn't warn or issue errors about attribute parameters that it doesn't use. This is by design, in part to aid in inflating Moose attributes when needed.
The next release will include better diagnostics when passing invalid arguments to has. It will croak about an odd number of options given.
Fixed in Moo 1.003001.