From: Nicholas Clark Date: Mon, 24 Aug 2009 13:17:11 +0000 (+0100) Subject: Fix a Deparse bug - constants and PCSs were appearing as subroutine stubs. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5b4ee54977204d4bae51b460a238c1c926c463d2;p=p5sagit%2Fp5-mst-13.2.git Fix a Deparse bug - constants and PCSs were appearing as subroutine stubs. (Because constants and other Proxy Constant Subroutines are stored in the symbol table as references, and in 5.11.0 RVs merged with IVs, and B::Deparse knows that an IV in the symbol table is a stub declaration for a subroutine with no prototype, so B::Deparse "knew" that that's what it was.) --- diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm index 5685d09..d0fa534 100644 --- a/ext/B/B/Deparse.pm +++ b/ext/B/B/Deparse.pm @@ -22,7 +22,7 @@ use B qw(class main_root main_start main_cv svref_2object opnumber perlstring PMf_MULTILINE PMf_SINGLELINE PMf_FOLD PMf_EXTENDED), ($] < 5.009 ? 'PMf_SKIPWHITE' : 'RXf_SKIPWHITE'), ($] < 5.011 ? 'CVf_LOCKED' : ()); -$VERSION = 0.89; +$VERSION = 0.90; use strict; use vars qw/$AUTOLOAD/; use warnings (); @@ -487,8 +487,11 @@ sub stash_subs { next unless $AF eq $0 || exists $self->{'files'}{$AF}; } push @{$self->{'protos_todo'}}, [$pack . $key, $val->PV]; - } elsif ($class eq "IV") { + } elsif ($class eq "IV" && !($val->FLAGS & SVf_ROK)) { # Just a name. As above. + # But skip proxy constant subroutines, as some form of perl-space + # visible code must have created them, be it a use statement, or + # some direct symbol-table manipulation code that we will Deparse my $A = $stash{"AUTOLOAD"}; if (defined ($A) && class($A) eq "GV" && defined($A->CV) && class($A->CV) eq "CV") { diff --git a/ext/B/t/deparse.t b/ext/B/t/deparse.t index eb5926f..0f87ea4 100644 --- a/ext/B/t/deparse.t +++ b/ext/B/t/deparse.t @@ -23,7 +23,7 @@ BEGIN { require feature; feature->import(':5.10'); } -use Test::More tests => 77; +use Test::More tests => 78; use Config (); use B::Deparse; @@ -127,6 +127,11 @@ LINE: while (defined($_ = )) { EOF is($a, $b); +$a = `$^X $path "-MO=Deparse" -e "use constant PI => 4" 2>&1`; +$a =~ s/-e syntax OK\n//g; +is($a, "use constant ('PI', 4);\n", + "Proxy Constant Subroutines must not show up as (incorrect) prototypes"); + #Re: perlbug #35857, patch #24505 #handle warnings::register-ed packages properly. package B::Deparse::Wrapper;