sub pp_entersub {
my $self = shift;
- $self->{brd_sub} = 1;
- my $body = $self->SUPER::pp_entersub(@_);
- $self->{brd_sub} = 0;
+ my $body = do {
+ local $self->{brd_sub} = 1;
+ $self->SUPER::pp_entersub(@_);
+ };
$body =~ s/^&\s*(\w)/$1/ if $self->_recurse;
return $body;
}
sub pp_refgen {
my $self = shift;
- $self->{brd_sub} = 0;
- my $body = $self->SUPER::pp_refgen(@_);
- $self->{brd_sub} = 1;
- return $body;
+ return do {
+ local $self->{brd_sub} = 0;
+ $self->SUPER::pp_refgen(@_);
+ }
}
sub pp_gv {
$body = $self->SUPER::pp_gv(@_);
} else {
my $gv = $self->gv_or_padgv($_[0]);
- ++$self->{brd_cur};
- $body = 'sub ' . $self->indent($self->deparse_sub($gv->CV));
- --$self->{brd_cur};
+ $body = do {
+ local @{$self}{qw/brd_sub brd_cur/} = (0, $self->{brd_cur} + 1);
+ 'sub ' . $self->indent($self->deparse_sub($gv->CV));
+ };
if (FOOL_SINGLE_DELIM) {
$body = $key . $body;
} else {
use strict;
use warnings;
-use Test::More tests => (3 + 3) * 5;
+use Test::More tests => (3 + 3) * 5 + 1;
use B::Deparse;
use B::RecDeparse;
$brd = B::RecDeparse->new(deparse => [ $br_args ], level => 3);
which $brd, [ ], [ qw/add mul fma/ ], 2;
+
+sub fakegv { return @_ }
+eval { $brd->coderef2text(sub { return fakegv() }) };
+is($@, '', 'don\'t croak on non-CV GV\'s at level >= 1');