develooper Front page | perl.moose | Postings from June 2009

Inherited attribute bug?

Thread Next
June 3, 2009 07:00
Inherited attribute bug?
Message ID:

Could someone please explain to me what I'm doing wrong here?

    #!/usr/bin/env perl

        package My::Base;
        use Moose;
        has some_method => ( default => 'foo' );
        package My::Class;
        use Moose;
        extends 'My::Base';
    print My::Base->new->some_method;
    Can't locate object method "some_method" via package "My::Base" at line 16.

Changing the some_method attribute to the following makes this go away:

    has some_method => ( is => 'rw', default => 'foo' );

(is => 'ro', default => 'foo') also works.

Is this a bug or have I misunderstood something?  This is Moose 0.79 and perl, v5.8.8 built for i486-linux-gnu-thread-multi. (Also fails on Solaris, so I doubt it's an OS issue).

If this is a bug, I'll file a report.

Buy the book         -
Tech blog            -
Twitter              -
Official Perl 6 Wiki -

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About