Reproduced with PPI 1.203 and Apple's stock Perl 5.8.8 on Mac 10.5
If you stick the following at the end of Schwern's program, you get
similarly surprising results:
use Data::Dumper;
print Dumper($sub);
print Dumper(PPI::Document->new($0)-
Show quoted text >find_first("PPI::Statement::Sub"));
$VAR1 = bless( {}, 'PPI::Statement::Sub' );
$VAR1 = bless( { ... lots of content ... }, 'PPI::Structure::Sub' );
This change DOES make a difference, to my surprise:
print "Third\n";
my $doc = PPI::Document->new($0);
my $sub2 = $doc->find_first("PPI::Statement::Sub");
print $sub2->block;
I tried saving to @sub instead of $sub, but that didn't help
I tried reordering code to make sure it wasn't a caching issue, but
that didn't help.
I tried renaming "$sub" to a non-keyword, but that didn't help.
I tried moving "sub foo {...}" to a separate file, but that didn't help.
I tried messing with the interior of "sub foo { ... }" but that didn't
help.
I wondered if wantarray() could be involved, but PPI::Node::find_first
and PPI::Document::new don't use that.
Is there something special about PPI::Statement::Sub? I didn't test
this idea.
Could PPI::XS be involved? I tried reordering the code to put "sub
foo {...}" at the top, followed by "BEGIN { $PPI::XS_DISABLE=1; }"
followed by the "use" statements, but that didn't help.
Chris
On Oct 28, 2009, at 1:58 AM, Michael G Schwern via RT wrote:
Show quoted text> Wed Oct 28 02:58:37 2009: Request 50902 was acted upon.
> Transaction: Ticket created by MSCHWERN
> Queue: PPI
> Subject: Here-docs not stringifying. Also deep weirdness.
> Broken in: 1.206
> Severity: Normal
> Owner: Nobody
> Requestors: mschwern@cpan.org
> Status: new
> Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=50902 >
>
>
> The attached program shows two bugs. Here-docs do not stringify, at
> least not when dumped as part of a sub.
>
> The second is really weird. This prints the routine:
>
> print PPI::Document->new($0)->find_first("PPI::Statement::Sub")-
> >block;
>
> This does not.
>
> my $sub = PPI::Document->new($0)->find_first("PPI::Statement::Sub");
> print $sub->block;
>
> They should be exactly equivalent. PPI shouldn't even see the
> difference. I hope its not a perl bug.
>
> This is perl, v5.10.1 (*) built for darwin-thread-multi-64int-
> ld-2level
>
> <test.plx>