From: Vincent Pit Date: Sun, 27 Feb 2011 20:36:38 +0000 (+0100) Subject: Don't recurse into empty subroutines X-Git-Tag: v0.05~2 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FB-RecDeparse.git;a=commitdiff_plain;h=4e39151fd9368d9061a337ae61c68e9769abcc62 Don't recurse into empty subroutines --- diff --git a/lib/B/RecDeparse.pm b/lib/B/RecDeparse.pm index fbce870..f2b3660 100644 --- a/lib/B/RecDeparse.pm +++ b/lib/B/RecDeparse.pm @@ -187,7 +187,8 @@ sub pp_gv { my $seen = $self->{brd_seen}; my $body; - if (!$self->{brd_sub} or !$self->_recurse or $seen->{$name} or !$$cv) { + if (!$self->{brd_sub} or !$self->_recurse or $seen->{$name} or !$$cv + or !$cv->isa('B::CV') or $cv->ROOT->isa('B::NULL')) { $body = $self->SUPER::pp_gv(@_); } else { $body = do { diff --git a/t/17-calls.t b/t/17-calls.t index 76e8a3c..99f5e4f 100644 --- a/t/17-calls.t +++ b/t/17-calls.t @@ -3,13 +3,14 @@ use strict; use warnings; -use Test::More tests => 2 * 4 * 6; +use Test::More tests => 2 * 4 * 7; use B::RecDeparse; my $brd = B::RecDeparse->new(level => -1); sub foo { 123 } +sub baz; my $pkg; my $coderef; @@ -24,6 +25,11 @@ my @tests = ( [ x3 => 'bar(@_)', 'bar' ], [ x4 => 'bar(shift)', 'bar' ], + [ d1 => 'baz()', 'baz' ], + [ d2 => 'baz(1)', 'baz' ], + [ d3 => 'baz(@_)', 'baz' ], + [ d4 => 'baz(shift)', 'baz' ], + [ c1 => '$coderef->()', 'coderef' ], [ c2 => '$coderef->(1)', 'coderef' ], [ c3 => '$coderef->(@_)', 'coderef' ],