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

Inherited attribute bug?

Thread Next
From:
Ovid
Date:
June 3, 2009 07:00
Subject:
Inherited attribute bug?
Message ID:
373355.19432.qm@web65708.mail.ac4.yahoo.com

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;
    __END__
    Can't locate object method "some_method" via package "My::Base" at inherit.pl 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.

Cheers,
Ovid
--
Buy the book         - http://www.oreilly.com/catalog/perlhks/
Tech blog            - http://use.perl.org/~Ovid/journal/
Twitter              - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About