Skip Menu |

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 67158
Status: resolved
Priority: 0/
Queue: Moose

People
Owner: Nobody in particular
Requestors: sean [...] blanton.com
Cc: randomcoder1 [...] gmail.com
AdminCc:

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



Subject: Unhelpful err msg when consumer and role have same sub
Getting this error message a Moose class consumes a role and both the class and the role have a sub with the same name: Undefined subroutine &Class::MOP::Mixin::HasMethods::body called at /usr/local/lib64/perl5/Class/MOP/Mixin/HasMethods.pm line 165. There is no normal Moose stack trace, only this message referring to the Class::MOP line #. It is a very mysterious message and when you are flying through code reorg and re-factoring, it stops you dead. Fortunately I now recognize the message, but the first time it took me literally an hour to figure out which module had the problem and what the problem was. Moose is awesome - thanks!
When a class consumes a role and they both provide the same method, there shouldn't be any warnings or errors at all - the class's method should just override the one from the role. Can you give a code sample which demonstrates the issue you're having?
I think the problem is with the actual error message. This error message should transmit that the role and the class have the same method. However the current error message is "Undefined subroutine &Class::MOP::Mixin::HasMethods::body called at /usr/local/lib64/perl5/Class/MOP/Mixin/HasMethods.pm line 165." So the error message says something is undefined, but in fact we have a duplicate sub in both the role and the class, these two things are confusing, one might later add the question, "what is actually undefined?" .. and personally I can't see an answer to that question. So, maybe we can find a better error message. Thank you for Moose! On Fri Apr 01 17:44:59 2011, DOY wrote: Show quoted text
> When a class consumes a role and they both provide the same method, > there shouldn't be any warnings or errors at all - the class's method > should just override the one from the role. Can you give a code sample > which demonstrates the issue you're having?
-- Your bugs , they are afraid of me.
Subject: Re: [rt.cpan.org #67158] Unhelpful err msg when consumer and role have same sub
Date: Mon, 4 Apr 2011 09:36:09 -0500
To: Petrea Corneliu Stefan via RT <bug-Moose [...] rt.cpan.org>
From: Jesse Luehrs <doy [...] tozt.net>
On Mon, Apr 04, 2011 at 07:00:12AM -0400, Petrea Corneliu Stefan via RT wrote: Show quoted text
> Queue: Moose > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=67158 > > > I think the problem is with the actual error message. > This error message should transmit that the role and the class have the > same method. > However the current error message is > > "Undefined subroutine &Class::MOP::Mixin::HasMethods::body called at > /usr/local/lib64/perl5/Class/MOP/Mixin/HasMethods.pm line 165." > > So the error message says something is undefined, but in fact we have a > duplicate sub in both the role and the class, these two things are > confusing, one might later add the question, "what is actually > undefined?" .. and personally I can't see an answer to that question. > > So, maybe we can find a better error message. > > Thank you for Moose!
No, the problem is that there shouldn't be any error message at all. If there is an error message, that is a bug, and should be fixed. I can't reproduce this though, so it'd be helpful if I could have a test case. -doy
On Mon Apr 04 10:36:23 2011, doy@tozt.net wrote: Show quoted text
> On Mon, Apr 04, 2011 at 07:00:12AM -0400, Petrea Corneliu Stefan via > RT wrote:
> > Queue: Moose > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=67158 > > > > > I think the problem is with the actual error message. > > This error message should transmit that the role and the class have
> the
> > same method. > > However the current error message is > > > > "Undefined subroutine &Class::MOP::Mixin::HasMethods::body called at > > /usr/local/lib64/perl5/Class/MOP/Mixin/HasMethods.pm line 165." > > > > So the error message says something is undefined, but in fact we
> have a
> > duplicate sub in both the role and the class, these two things are > > confusing, one might later add the question, "what is actually > > undefined?" .. and personally I can't see an answer to that
> question.
> > > > So, maybe we can find a better error message. > > > > Thank you for Moose!
> > No, the problem is that there shouldn't be any error message at all. > If > there is an error message, that is a bug, and should be fixed. I can't > reproduce this though, so it'd be helpful if I could have a test case. > > -doy
I've encountered it twice a few months apart. I'll work on a test case.
(Sorry this took so long) I'm able to reproduce this with a simple case - am I doing something wrong? Also, clearly this is related to accessors, not subs - sorry about that. prog_role.pm: -------------------------- package prog_role; use Moose::Role; has location_id => ( is => 'rw', ); no Moose::Role; 1; -------------------------- prog.pm -------------------------- package prog; use Moose; with 'prog_role'; has location_id => ( is => 'rw', ); no Moose; 1; -------------------------- Then run 'perl prog.pm' I get: "Undefined subroutine &Class::MOP::Mixin::HasMethods::body called at /usr/local/lib64/perl5/Class/MOP/Mixin/HasMethods.pm line 165." I've tried changing the two accessors to have different defaults, added a '+' to the overriding one, and I always get the same thing. On Mon Apr 04 11:21:41 2011, sblanton wrote: Show quoted text
> On Mon Apr 04 10:36:23 2011, doy@tozt.net wrote:
> > On Mon, Apr 04, 2011 at 07:00:12AM -0400, Petrea Corneliu Stefan via > > RT wrote:
> > > Queue: Moose > > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=67158 > > > > > > > I think the problem is with the actual error message. > > > This error message should transmit that the role and the class
have Show quoted text
> > the
> > > same method. > > > However the current error message is > > > > > > "Undefined subroutine &Class::MOP::Mixin::HasMethods::body called
at Show quoted text
> > > /usr/local/lib64/perl5/Class/MOP/Mixin/HasMethods.pm line 165." > > > > > > So the error message says something is undefined, but in fact we
> > have a
> > > duplicate sub in both the role and the class, these two things are > > > confusing, one might later add the question, "what is actually > > > undefined?" .. and personally I can't see an answer to that
> > question.
> > > > > > So, maybe we can find a better error message. > > > > > > Thank you for Moose!
> > > > No, the problem is that there shouldn't be any error message at all. > > If > > there is an error message, that is a bug, and should be fixed. I
can't Show quoted text
> > reproduce this though, so it'd be helpful if I could have a test
case. Show quoted text
> > > > -doy
> > I've encountered it twice a few months apart. I'll work on a test
case.
Subject: Re: [rt.cpan.org #67158] Unhelpful err msg when consumer and role have same sub
Date: Sun, 17 Jul 2011 17:00:51 -0500 (CDT)
To: Sean Blanton via RT <bug-Moose [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Thu, 14 Jul 2011, Sean Blanton via RT wrote: Show quoted text
> (Sorry this took so long) I'm able to reproduce this with a simple case > - am I doing something wrong? Also, clearly this is related to > accessors, not subs - sorry about that. > > prog_role.pm: > -------------------------- > package prog_role; > > use Moose::Role; > > has location_id => ( > is => 'rw', > ); > > no Moose::Role; > > 1; > -------------------------- > > prog.pm > -------------------------- > package prog; > > use Moose; > > with 'prog_role'; > > has location_id => ( > is => 'rw', > ); > > no Moose; > > 1; > -------------------------- > > Then run 'perl prog.pm' > > I get: > > "Undefined subroutine &Class::MOP::Mixin::HasMethods::body called at > /usr/local/lib64/perl5/Class/MOP/Mixin/HasMethods.pm line 165."
I cannot reproduce this. Are you using a recent version of Moose? The latest stable version is 2.0010. Thanks, -dave /*============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================*/
On Sun Jul 17 18:01:00 2011, autarch@urth.org wrote: Show quoted text
> On Thu, 14 Jul 2011, Sean Blanton via RT wrote: >
> > (Sorry this took so long) I'm able to reproduce this with a simple
case Show quoted text
> > - am I doing something wrong? Also, clearly this is related to > > accessors, not subs - sorry about that. > > > > prog_role.pm: > > -------------------------- > > package prog_role; > > > > use Moose::Role; > > > > has location_id => ( > > is => 'rw', > > ); > > > > no Moose::Role; > > > > 1; > > -------------------------- > > > > prog.pm > > -------------------------- > > package prog; > > > > use Moose; > > > > with 'prog_role'; > > > > has location_id => ( > > is => 'rw', > > ); > > > > no Moose; > > > > 1; > > -------------------------- > > > > Then run 'perl prog.pm' > > > > I get: > > > > "Undefined subroutine &Class::MOP::Mixin::HasMethods::body called at > > /usr/local/lib64/perl5/Class/MOP/Mixin/HasMethods.pm line 165."
> > I cannot reproduce this. Are you using a recent version of Moose? The > latest stable version is 2.0010. > > > Thanks, > > -dave > > /*============================================================ > http://VegGuide.org http://blog.urth.org > Your guide to all that's veg House Absolute(ly Pointless) > ============================================================*/
I think the bug has been fixed. I can't reproduce the bug either with Moose 2.0010 -- Your bugs , they are afraid of me.
Yes, fixed in latest version. Thanks for your time!