Commit
2eaf799e74b stop most declarations like ‘sub foo{}’ from creat-
ing GVs. Instead, simple sub refs are stored in the stash.
That broke deparsing of package subs:
$ perl5.21.4 -MO=Deparse -e 'sub foo{die}'
-e syntax OK
Deparse needs to know about these references, so that we get this:
$ ./perl -Ilib -MO=Deparse -e 'sub foo{die}'
sub foo {
die;
}
-e syntax OK
next unless $AF eq $0 || exists $self->{'files'}{$AF};
}
push @{$self->{'protos_todo'}}, [$pack . $key, undef];
+ } elsif ($class eq "IV") {
+ # A reference. Dump this if it is a reference to a CV.
+ if (class(my $cv = $val->RV) eq "CV") {
+ $self->todo($cv, 0);
+ }
} elsif ($class eq "GV") {
if (class(my $cv = $val->CV) ne "SPECIAL") {
next if $self->{'subs_done'}{$$val}++;
use strict;
use Test::More;
-my $tests = 25; # not counting those in the __DATA__ section
+my $tests = 26; # not counting those in the __DATA__ section
use B::Deparse;
my $deparse = B::Deparse->new();
like($a, qr/my sub __DATA__;\n\(\);\nCORE::__DATA__/,
'CORE::__DATA__ after my sub __DATA__');
+# sub declarations
+$a = readpipe qq`$^X $path "-MO=Deparse" -e "sub foo{}" 2>&1`;
+like($a, qr/^sub foo\s*\{\s+\}/, 'sub declarations');
+
done_testing($tests);