Subject: | Delegating 'accessor' method of native Hash rejects values as invalid keys |
The native Hash trait's method 'accessor' rejects its $value argument as
being an invalid key with the message "The key passed to accessor must be
a defined value".
That is, $obj->delegated_accessor(foo => undef); will fail despite the
definedness of 'foo'.
Attached is a simple test case; note that the bug exists in both forms of
delegation.
Subject: | attr-delegation.pl |
#!/usr/bin/perl
use warnings;
use strict;
package Thing;
use Moose;
has hashref => (
is => 'ro',
traits => ['Hash'],
default => sub { {} },
handles => {
attr => [qw(accessor attr)],
access => 'accessor',
},
);
__PACKAGE__->meta->make_immutable;
package main;
my $thing = Thing->new;
eval { $thing->attr(undef); };
warn if $@;
eval { $thing->access(attr => undef); };
warn if $@;