Skip Menu |

This queue is for tickets about the Devel-Graph CPAN distribution.

Report information
The Basics
Id: 29346
Status: open
Worked: 15 min
Priority: 0/
Queue: Devel-Graph

People
Owner: TELS [...] cpan.org
Requestors: moghroth [...] gmail.com
Cc:
AdminCc:

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



Subject: decompose fails on a closure, for loop and until loop
Devel::Graph version 0.10 The attached file is a test for failure on parsing a closure. Subsequent investigations have also shown that for and unless loops fail similarly. The error seems to be in the private method _parse_compound, and is thrown by the test for 'PPI::Structure::Condition'. Neither a closure nor a loop will satisfy this test. **** # work around closure bug return $self->_parse($element->children) if $type eq 'continue'; return $self->_parse_loop($element) if $type eq 'for' || $type eq 'foreach'; $self->error("Cannot find condition: possible syntax error in $element") unless defined $self->_find_first( $element, 'PPI::Structure::Condition' ); ****
Subject: closure.t
#!/usr/bin/perl -w use Test::More; use strict; BEGIN { plan tests => 4; chdir 't' if -d 't'; use lib '../lib'; use_ok ("Devel::Graph") or die($@); }; ############################################################################# # croak on errors my $grapher = Devel::Graph->new(); is (ref($grapher), 'Devel::Graph'); my $if_code = <<'IF_CODE'; my $a = 1; if($a){ my $var = 1; my $other_var = 2; my $var_now = $var + $other_var; print "$var_now\n"; } IF_CODE eval "\$grapher->decompose( \\\$if_code )"; is ($@, '', 'if error'); my $closure_code = <<'CLOSURE_CODE'; { my $var = 1; my $other_var = 2; my $var_now = $var + $other_var; print "$var_now\n"; } CLOSURE_CODE eval "\$grapher->decompose( \\\$closure_code )"; is ($@, '', 'closure error');
On Thu Sep 13 13:42:10 2007, moghroth@gmail.com wrote: Show quoted text
> Devel::Graph version 0.10
Thanx for your report! I have just pushed v0.11 to CPAN that contains this fix and two testfiles for closures and for/until loops. If you find anything else, please report it in a separate bugreport. Please note that Graph::Devel uses PPI to parse the Perl code, but PPI only parses the syntax and doesn't do any semantic analysis. This means that even invalid Perl code will be parsed by PPI just fine, and the caller needs to figure out what the generated tree actually means. And this is quite hard, especially solving it in a general and recursive manner. So please go find bugs in my code and report them :) all the best, tels
Subject: Re: [rt.cpan.org #29346] decompose fails on a closure, for loop and until loop
Date: Wed, 19 Sep 2007 02:20:24 +0100
To: bug-Devel-Graph [...] rt.cpan.org
From: Brían Mach Aon Innéirghthe <moghroth [...] gmail.com>
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 15 MFómh 2007, at 21:53, via RT wrote: Show quoted text
> Please note that Graph::Devel uses PPI to parse the Perl code, but PPI > only parses the syntax and doesn't do any semantic analysis. This means > that even invalid Perl code will be parsed by PPI just fine, and the > caller needs to figure out what the generated tree actually means. > > And this is quite hard, especially solving it in a general and > recursive > manner.
Syntax and semantics !!! 27 by 11 is, first, last, Show quoted text
>together<
B Brían Mach Aon Innéirghthe Corcaigh Éire -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Darwin) iD8DBQFG8HlZCS8qwOrvIcsRArG9AJ9E/eS/jSLJr7ubSzqfpunvFAq4VgCcDdYn ekBtpea6k9EyhCP185RkJEg= =Hi3c -----END PGP SIGNATURE-----
hello, sorry for the late response, somehow RT did not forward your message to me. In any event, I do not understand your reply :( Can you please rephrase it? On Tue Sep 18 21:22:14 2007, moghroth@gmail.com wrote: Show quoted text
> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > On 15 MFómh 2007, at 21:53, via RT wrote: >
> > Please note that Graph::Devel uses PPI to parse the Perl code, but PPI > > only parses the syntax and doesn't do any semantic analysis. This means > > that even invalid Perl code will be parsed by PPI just fine, and the > > caller needs to figure out what the generated tree actually means. > > > > And this is quite hard, especially solving it in a general and > > recursive > > manner.
> > Syntax and semantics !!! > > 27 by 11 is, > > first, last, >
> >together<
> > B