This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix B::Xref to handle sub refs
authorFather Chrysostomos <sprout@cpan.org>
Mon, 9 Oct 2017 05:22:30 +0000 (22:22 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 9 Oct 2017 05:22:30 +0000 (22:22 -0700)
This only applies to non-threaded builds.  Threaded builds were
already fine.

ext/B/B/Xref.pm

index 255ee89..a4b8b2a 100644 (file)
@@ -143,7 +143,7 @@ Malcolm Beattie, mbeattie@sable.ox.ac.uk.
 use strict;
 use Config;
 use B qw(peekop class comppadlist main_start svref_2object walksymtable
-         OPpLVAL_INTRO SVf_POK OPpOUR_INTRO cstring
+         OPpLVAL_INTRO SVf_POK SVf_ROK OPpOUR_INTRO cstring
         );
 
 sub UNKNOWN { ["?", "?", "?"] }
@@ -331,7 +331,13 @@ sub pp_gv {
     }
     else {
        $gv = $op->gv;
-       $top = [$gv->STASH->NAME, "*", $gv->SAFENAME];
+       if ($gv->FLAGS & SVf_ROK) { # sub ref
+           my $cv = $gv->RV;
+           $top = [$cv->STASH->NAME, '*', B::safename($cv->NAME_HEK)]
+       }
+       else {
+           $top = [$gv->STASH->NAME, '*', $gv->SAFENAME];
+       }
     }
     process($top, $op->private & OPpLVAL_INTRO ? "intro" : "used");
 }