Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the PPI CPAN distribution.

Report information
The Basics
Id: 50902
Status: resolved
Priority: 0/
Queue: PPI

People
Owner: Nobody in particular
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.206
Fixed in: (no value)



Subject: Here-docs not stringifying. Also deep weirdness.
Download (untitled) / with headers
text/plain 525b
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
Subject: test.plx
Download test.plx
application/octet-stream 336b

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #50902] Here-docs not stringifying. Also deep weirdness.
Date: Wed, 28 Oct 2009 05:00:14 -0500
To: bug-PPI [...] rt.cpan.org
From: Chris Dolan <chris [...] chrisdolan.net>
Download (untitled) / with headers
text/plain 2.3k
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>
Subject: Re: [rt.cpan.org #50902] Here-docs not stringifying. Also deep weirdness.
Date: Wed, 28 Oct 2009 05:03:16 -0500
To: bug-PPI [...] rt.cpan.org
From: Chris Dolan <chris [...] chrisdolan.net>
Download (untitled) / with headers
text/plain 1.3k
Aha! Never mind my last message. Here's the source of the problem: PPI::Node::add_element contains: Scalar::Util::weaken( $_PARENT{refaddr $Element} = $self ); So, in the inline code the PPI::Document instance still exists while in the $sub version, the PPI::Document instance has already been garbage collected. 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>
Subject: Re: [rt.cpan.org #50902] Here-docs not stringifying. Also deep weirdness.
Date: Wed, 28 Oct 2009 15:26:55 -0700
To: bug-PPI [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
Download (untitled) / with headers
text/plain 415b
Chris Dolan via RT wrote: Show quoted text
> 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.
I don't have PPI::XS installed. -- 44. I am not the atheist chaplain. -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army http://skippyslist.com/list/
Download (untitled) / with headers
text/plain 236b
In the second case, you allowed the document as a whole to be garbage collected. For the moment, this behaviour is expected. If you wish to keep a part of a document when the rest of the document is destroyed, you need to ->remove it.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.