Subject: | Error message from inside of module when used property w/Array trait |
Date: | Fri, 07 May 2010 11:04:19 +0200 |
To: | <bug-Moose [...] rt.cpan.org> |
From: | <roman.hubacek [...] centrum.cz> |
When a class is using property with Array native trait, errors are reported from within a Moose::Meta::Attribute::Native::MethodProvider::Array module.
Short example:
------------------------------------
package Cls;
use Moose;
has an_array => (
traits => ['Array'],
isa => 'ArrayRef[Str]',
is => 'rw',
# !!! forgotten default to empty array
handles => {
add_item => 'push',
},
);
package main;
my $c = Cls->new();
$c->add_item('String');
------------------------------------
The code yields this error message:
Can't use an undefined value as an ARRAY reference at d:/Prog/Perl/site/lib/Moose/Meta/Attribute/Native/MethodProvider/Array.pm line 130.
Preferrably this could error at line with $c->add_item('String'). I am using Moose 1.02 with ActivePerl 5.10.0 on WinXP.
-- thanks a lot. Roman