Subject: | Another ProhibitCaptureWithoutTest false positive |
I know there are already open bugs against this policy, but here's one
more example to consider if and when you get round to fixing it:
#!/usr/bin/perl
# $Id: $
use warnings;
use strict;
use Carp qw(croak);
our $VERSION = 1;
my @a = qw(abc def);
foreach (@a) {
/(a)/sxm or ( carp('no match'), next );
my $x = $1;
print "$x\n" or croak;
}
There is a test that the regexp matches - and this is reasonably
idiomatic, if dense, Perl code. But ProhibitCaptureWithoutTest warns.
Perhaps the warning should only fire if static analysis can prove that
the capture variable is definitely used later no matter what the result
of the regexp match - which would give some false negatives, but
eliminate the false positives.