Subject: | Calling new() in a BEGIN block on a class with a BUILD method caused a warning. |
{
package Bar;
use Mouse;
sub BUILD {}
}
BEGIN {
Bar->new;
}
This results in 'Name "Mouse::Object::BUILD" used only once: possible
typo at lib/Mouse/Object.pm line 54.'. Adding "no warnings 'once';" to
the do block is one way to handle it. Its broken in both 0.37 and master.
--- a/lib/Mouse/Object.pm
+++ b/lib/Mouse/Object.pm
@@ -51,7 +51,7 @@ sub BUILDALL {
return unless $self->can('BUILD');
for my $class (reverse $self->meta->linearized_isa) {
- my $build = do{ no strict 'refs'; *{ $class . '::BUILD' }{CODE} }
+ my $build = do{ no strict 'refs'; no warnings 'once'; *{ $class
. '::BUILD' }{CODE} }
or next;
$self->$build(@_);