Skip Menu |

This queue is for tickets about the Moo CPAN distribution.

Report information
The Basics
Id: 103804
Status: resolved
Priority: 0/
Queue: Moo

People
Owner: Nobody in particular
Requestors: book [...] cpan.org
Cc:
AdminCc:

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



Subject: Moo does not differentiate stubs from actual methods
Here's an example: perl -e ' package Interface; use Moo::Role; requires q{attr}; package Class; use Moo; with q{Interface}; has attr => ( is => q{ro} ); ' Which fails with: Can't apply Interface to Class - missing attr at /home/book/perl5/lib/perl5/Role/Tiny.pm line 317. OK, so I'll fix it with a stub: perl -e ' package Interface; use Moo::Role; requires q{attr}; package Class; use Moo; with q{Interface}; sub attr; # stub has attr => ( is => q{ro} ); ' But that fails with: You cannot overwrite a locally defined method (attr) with a reader at /home/book/perl5/lib/perl5/Method/Generate/Accessor.pm line 30. It should be possible to see the difference between a stub and actual code reference.
On Sat Apr 18 05:53:04 2015, BOOK wrote: Show quoted text
> Here's an example: > > perl -e ' > package Interface; > use Moo::Role; > requires q{attr}; > > package Class; > use Moo; > with q{Interface}; > has attr => ( is => q{ro} ); > ' >
Known workarounds: # ensure the 'with' is executed after the 'has', at runtime: perl -e ' package Interface; use Moo::Role; requires q{attr}; package Class; use Moo; has attr => ( is => q{ro} ); with q{Interface}; ' # declare the attribute at compile time: perl -e ' package Interface; use Moo::Role; requires q{attr}; package Class; use Moo; with q{Interface}; BEGIN { has attr => ( is => q{ro} ); } '
This is fixed in git. New release should happen within the next few weeks. Thanks for the report.
Fixed in 2.000002