Perl-Critic / PPI

53 stars 44 forks source link

Subroutines with names starting with an 'x' are misparsed #197

Closed thoughtstream closed 7 years ago

thoughtstream commented 7 years ago

The two documents produced by the following code should have identical structures, but they don't. The first document parses correctly. However, in the second document, the subroutine name 'x1' is incorrectly parsed as an operator ('x') followed by a number ('1'):

use Data::Dumper 'Dumper';
use PPI;

print Dumper( PPI::Document->new( \ 'sub X1 {}' ) );
print Dumper( PPI::Document->new( \ 'sub x1 {}' ) );

A suitable additional unit test would be:

use Test::More;
plan tests => 2;

use PPI;

ok( PPI::Document->new( \ 'sub X1 {}' )->find('PPI::Statement::Sub')  => 'sub X1' );
ok( PPI::Document->new( \ 'sub x1 {}' )->find('PPI::Statement::Sub')  => 'sub x1' );

done_testing();
moregan commented 7 years ago

A fix for this has been committed to PPI, and is waiting to be released: https://github.com/adamkennedy/PPI/issues/122 As I recall, PPI still needs to have some regressions addressed before its next release.

wchristian commented 7 years ago

That is correct and i'm working on resolving more of those.

wchristian commented 7 years ago

It is now fixed and released. :)