Subject: | Autoloaded methods in void context croak unnecessarily |
Calling a autoloaded method in void context on an
Object::Destroyer-wrapped object causes it to croak(), although the
method call is completed successfully.
A return() in the branch that handles void context should do it, I think.
Here's a test:
#!/usr/bin/perl
use strict;
use warnings;
BEGIN {
$| = 1;
$^W = 1;
}
use Test::More tests => 2;
my $foo = Foo->new;
# this works
ok($foo->autoloaded_method);
# this will croak..
$foo->autoloaded_method;
ok( 1 );
# okay that was a huge hack, but I can't think of a better way
# to test something in called void context doesn't die..
exit(0);
package Foo;
use Object::Destroyer;
use vars qw($AUTOLOAD);
sub new{
my $class = shift;
bless my $self = {}, $class;
return Object::Destroyer->new($self);
}
sub AUTOLOAD{
my $self = shift;
return "$AUTOLOAD\n";
}
sub DESTROY{}
1;