Skip Menu |

This queue is for tickets about the MooseX-ClassAttribute CPAN distribution.

Report information
The Basics
Id: 73918
Status: open
Priority: 0/
Queue: MooseX-ClassAttribute

People
Owner: Nobody in particular
Requestors: llap [...] cuckoo.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.26
Fixed in: (no value)



Subject: Bug with overwride on class_has
Using 'override' caused a bug Moose version 2.0008 Here is how to replicate (also as a gist: https://gist.github.com/1471606); ----- package My::Base; use Moose; use MooseX::ClassAttribute; class_has 'foo' => ( is => 'rw', isa => 'Str', lazy_build => 1, ); sub _build_foo { die "setup in child" }; __PACKAGE__->meta()->make_immutable(); no Moose; no MooseX::ClassAttribute; package My::A; use Moose; use MooseX::ClassAttribute; extends 'My::Base'; override '_build_foo' => sub { return 'a' }; package My::B; use Moose; use MooseX::ClassAttribute; extends 'My::Base'; override '_build_foo' => sub { return 'b' }; package main; my $a = My::A->new(); my $b = My::B->new(); print "A -> " . $a->foo() . "\n"; print "B -> " . $b->foo() . "\n"; -------- Result: Show quoted text
>perl test.pl
A -> a B -> a
On Thu Jan 12 09:00:19 2012, llap@cuckoo.org wrote: Show quoted text
> Using 'override' caused a bug
also doesn't work using 'sub {}' instead of override, and with no lazy_build: package My::Base; use Moose; use MooseX::ClassAttribute; class_has 'foo' => ( is => 'rw', isa => 'Str', builder => '_build_foo', lazy => 1, ); sub _build_foo { die "not set"; } __PACKAGE__->meta()->make_immutable(); no Moose; no MooseX::ClassAttribute; package My::A; use Moose; use MooseX::ClassAttribute; extends 'My::Base'; sub _build_foo { return 'a'; } package My::B; use Moose; use MooseX::ClassAttribute; extends 'My::Base'; sub _build_foo { return 'b'; } package main; my $a = My::A->new(); my $b = My::B->new(); print "A -> " . $a->foo . "\n"; print "B -> " . $b->foo . "\n";