Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Perl-Critic CPAN distribution.

Report information
The Basics
Id: 49442
Status: resolved
Priority: 0/
Queue: Perl-Critic

People
Owner: Nobody in particular
Requestors: user42 [...] zip.com.au
Cc:
AdminCc:

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



Subject: fatal error critiquing perl 5.10 regexp
Date: Sat, 05 Sep 2009 08:03:10 +1000
To: bug-Perl-Critic [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
With the current cvs and two files foo.pl and bar.pl both containing $x =~ /^([a-z])++/ running perlcritic foo.pl bar.pl gets a fatal error on foo.pl Fatal error while critiquing "foo.pl": Nested quantifiers; marked by <-- HERE in m/^([a-z])++ <-- HERE / at /usr/share/perl5/Regexp/Parser/Objects.pm line 719 and doesn't go on to critique bar.pl, whereas I hoped that a perl 5.10 regexp like in foo.pl wouldn't prevent bar.pl from being processed, and preferrably wouldn't prevent other aspects of foo.pl being processed either. I suspect Regexp::Parser 0.20 doesn't fully determine its errors when the string is set in, but instead croaks in later operations, which perlcritic takes to be an un-continuable error (probably reasonable). I get some joy from protecting per below.
Index: PPIRegexp.pm =================================================================== --- PPIRegexp.pm (revision 3613) +++ PPIRegexp.pm (working copy) @@ -61,6 +61,15 @@ return if ! $parser->regex($re); } + # The docs of Regexp::Parser 0.20 seem to say its errors and warnings are + # determined at the ->regexp stage, but some perl 5.10 forms like + # /^([a-z])++/ cause a croak() at the subsequent ->parse stage. Dunno if + # it's the code or docs which are right or wrong, but as a workaround + # parse now instead of dying later in one of the methods which depend on + # the parse being done, like $parser->captures or whatnot. + # + return unless eval { $parser->parse; 1 }; + return $parser; }
On Fri Sep 04 18:04:15 2009, user42@zip.com.au wrote: Show quoted text
> With the current cvs and two files foo.pl and bar.pl both containing > > $x =~ /^([a-z])++/ > > running > > perlcritic foo.pl bar.pl > > gets a fatal error on foo.pl > > Fatal error while critiquing "foo.pl": Nested quantifiers; marked > by <-- HERE in m/^([a-z])++ <-- HERE / at > /usr/share/perl5/Regexp/Parser/Objects.pm line 719 > > and doesn't go on to critique bar.pl, whereas I hoped that a perl 5.10 > regexp like in foo.pl wouldn't prevent bar.pl from being processed, > and > preferrably wouldn't prevent other aspects of foo.pl being processed > either. > > I suspect Regexp::Parser 0.20 doesn't fully determine its errors when > the string is set in, but instead croaks in later operations, which > perlcritic takes to be an un-continuable error (probably reasonable). > I get some joy from protecting per below. >
The proposed replacement of Regexp::Parser with PPIx::Regexp appears to fix this, at least for the given regexp. This was committed a while back as SVN revision 3704. It's not in a production release yet, but it appears to be in 1.105_02.