The problem is, this is sloppy:
ClassName->new
It will behave differently depending on whether or not there is a sub called ClassName in the current package. This is a pretty hard to debug error, and is not really Moose's fault. The following snippet illustrates the problem and doesn't use Moose anywhere...
use 5.010; use strict; use LWP::UserAgent; { package ClassName; sub new { bless [@_], $_[0] } } { package main; sub ClassName () { 'LWP::UserAgent' }; my $obj = ClassName->new; say ref $obj; # says "LWP::UserAgent" }
The solution is to institute a policy of never using the BareWord->method syntax. Better, and unambiguous ways of writing ClassName->new are:
ClassName::->new # or... 'ClassName'->new
Update: aliased is also a rather nice solution.
In reply to Re: MooseX obscure error and importance of Unit Testing
by tobyink
in thread MooseX obscure error and importance of Unit Testing
by greengaroo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |