我正在尝试扩展一个非 moose 类,当我调用 moose 为我的扩展类定义的访问器时,我收到以下错误:
Not a HASH reference at accessor MyGraph::weight (defined at MyGraph.pm line 8) line 8
这是简化的代码:
package MyGraph;
use Moose;
use MooseX::NonMoose;
extends 'Graph';
has 'weight' => (
is => 'ro',
isa => 'Num',
);
no Moose;
__PACKAGE__->meta->make_immutable;
package main;
my $g = MyGraph->new;
$g->weight();