Subject: | Deep recursion on subroutine "Method::Generate::Accessor::_SIGDIE" |
I get the error Deep recursion on subroutine "Method::Generate::Accessor::_SIGDIE" when
running the attached test script. The attached patched fixes it but I'm not sure that
it is a genuine fix or whether I've just stumbled across it by chance. I suppose it
could also be the type library but I don't think I'm doing anything strange in there.
Subject: | accessor.patch |
--- Accessor.orig.pm 2013-08-02 22:19:21.000000000 +0100
+++ Accessor.pm 2013-08-03 13:27:14.000000000 +0100
@@ -5,7 +5,7 @@
use base qw(Moo::Object);
use Sub::Quote;
use B 'perlstring';
-use Scalar::Util 'blessed';
+use Scalar::Util qw( blessed refaddr );
use overload ();
use Module::Runtime qw(use_module);
BEGIN {
@@ -404,12 +404,19 @@
.' name => '.B::perlstring($name).",\n"
.' step => '.B::perlstring($prefix).",\n"
." };\n"
- .' local $Method::Generate::Accessor::OrigSigDie = $SIG{__DIE__};'."\n"
- .' local $SIG{__DIE__} = \&Method::Generate::Accessor::_SIGDIE;'."\n"
+ .' &Method::Generate::Accessor::__is_die_set() or ('."\n"
+ .' local $Method::Generate::Accessor::OrigSigDie = $SIG{__DIE__} and '."\n"
+ .' local $SIG{__DIE__} = \&Method::Generate::Accessor::_SIGDIE);'."\n"
.$inside
."}\n"
}
+sub __is_die_set {
+ return refaddr( $SIG{__DIE__} )
+ && $Method::Generate::Accessor::OrigSigDie && refaddr( $SIG{__DIE__} )
+ == refaddr( $Method::Generate::Accessor::OrigSigDie ) ? 1 : 0;
+}
+
sub _generate_isa_check {
my ($self, $name, $value, $check, $init_arg) = @_;
$self->_generate_die_prefix(
Subject: | accessor.t |
# @(#)Ident: accessor.t 2013-08-03 19:05 pjf ;
use strict;
use warnings;
{ package Accessor::Test::Role;
use File::DataClass::Types qw( Directory Path );
use Moo::Role;
has 'dir' => is => 'lazy', isa => Directory,
coerce => Directory->coercion, default => 'dummy';
has 'index' => is => 'lazy', isa => Path, coerce => Path->coercion,
default => sub { $_[ 0 ]->dir->catfile( 'index.json' ) };
}
{ package Accessor::Test;
use Moo;
with q(Accessor::Test::Role);
}
my $prog = Accessor::Test->new(); $prog->index;