Perl-Critic / PPI

54 stars 44 forks source link

use signatures not supported by PPI #259

Closed jackdeguest closed 2 years ago

jackdeguest commented 3 years ago

Hello,

I am the author of Nice::Try which uses PPI (version 1.270), and I got an interesting bug report from perl monks here: https://www.perlmonks.org/?node_id=11133983

This script snippet when parsed by PPI yield unmatched braces because of the subroutine attributes in the try block:

use strict;
use warnings;
use experimental 'signatures';
use Nice::Try;

sub foo { 1 }
try {
  my $k = sub ($f = foo()) {};
}
catch ($e) {
  warn "caught: $e";
}
__END__

PPI gets confused and sees this as a PPI::Statement with content:

try {
  my $k = sub ($f = foo()

followed by a PPI::Statement::UnmatchedBrace with value ) and then a PPI::Statement with value {}

oalders commented 2 years ago

Thanks for this @jackdeguest. I think we can close this and track the issue via #194