Subject: | Sub redefined warning when using Moose's make_immutable() |
The code below reproduces the error below and the simple patch
below seems to resolve it easily enough. The cause seems to be
that Moose's make_immutable() creates a UNIVERSAL::DEMOLISH().
Then S::D creates two of them...
Thanks,
jdv
<error>
Subroutine Scalar::Defer::Deferred::DEMOLISH redefined at
.../lib/perl5/site_perl/5.8.8/Scalar/Defer.pm line 125.
</error>
<patch>
--- Defer.pm 2008-11-12 17:08:31.000000000 -0500
+++ Defer.pm.new 2008-11-12 17:07:59.000000000 -0500
@@ -101,7 +101,7 @@
};
{
- foreach my $sym (grep { $_ ne 'DESTROY' and $_ ne 'BEGIN' and
$_ ne 'END' and $_ ne 'AUTOLOAD' } keys %UNIVERSAL::) {
+ foreach my $sym (grep { $_ ne 'DEMOLISH' and $_ ne 'DESTROY'
and $_ ne 'BEGIN' and $_ ne 'END' and $_ ne 'AUTOLOAD' } keys
%UNIVERSAL::) {
my $code = q[
sub $sym {
if ( defined Scalar::Util::blessed($_[0]) ) {
</patch>
<code>
defer.pl:
#!/usr/local/bin/perl
use Foo;
use Scalar::Defer;
Foo.pm:
package Foo;
use Moose;
__PACKAGE__->meta->make_immutable();
1;
</code>