Skip Menu |

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 83861
Status: open
Priority: 0/
Queue: Moose

People
Owner: Nobody in particular
Requestors: ipluta [...] wp.pl
Cc: CHOROBA [...] cpan.org
AdminCc:

Bug Information
Severity: (no value)
Broken in: 2.0604
Fixed in: (no value)



Subject: no warning about overwriting a locally defined method with an accessor in a Role
This code runs without any warning about overwriting as sub with an accessor: package Foo; use Moose::Role; has bar => ( is => 'rw', default => "has bar", ); sub bar { return "sub bar"; } package Self; use Moose; with 'Foo'; package main; my $self = Self->new; print $self->bar; Doing a similar but within a Moose class: package Foo; use Moose; has bar => ( is => 'rw', default => "has bar", ); sub bar { return "sub bar"; } package main; my $self = Foo->new; print $self->bar; raises a complaint like: "You are overwriting a locally defined method (bar) with an accessor at ..." Shouldn't the role behavior follow the class behavior rather than silently ignoring an accessor overwrtiting a method?
From: ipluta [...] wp.pl
I marked "broken in 2.0604" but that only means that I tested on this version, not that this version broke the feature.
This is definitely a bug, but fixing it is hard. There's a long outstanding todo item for Moose which involves improving how attributes in roles act. Basically, right now we don't know what methods an attribute in a role will generate until the role is applied to a class. To fix this bug (and several others), we need to be able to calculate the methods earlier. Being able to do so will also let us fix a number of other problems.
PR#19 offers the possibility of fixing this.
Interestingly, changing Moose::Role to Moo::Role makes it work as expected.