In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/fe8d6c18fac3e6f25c32980e576a7fad32b20962?hp=8c225ab79ea4360be9f3c8f4accb055adc2a9269>
- Log ----------------------------------------------------------------- commit fe8d6c18fac3e6f25c32980e576a7fad32b20962 Author: Father Chrysostomos <spr...@cpan.org> Date: Fri Oct 24 18:20:01 2014 -0700 Deparse stash subs stores as RVs 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 ----------------------------------------------------------------------- Summary of changes: lib/B/Deparse.pm | 5 +++++ lib/B/Deparse.t | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/B/Deparse.pm b/lib/B/Deparse.pm index 53f4e6b..e327256 100644 --- a/lib/B/Deparse.pm +++ b/lib/B/Deparse.pm @@ -638,6 +638,11 @@ sub stash_subs { 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}++; diff --git a/lib/B/Deparse.t b/lib/B/Deparse.t index 8db86c1..66127ae 100644 --- a/lib/B/Deparse.t +++ b/lib/B/Deparse.t @@ -13,7 +13,7 @@ use warnings; 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(); @@ -323,6 +323,10 @@ $a = readpipe qq`$^X $path "-MO=Deparse" -Xe ` 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); -- Perl5 Master Repository