You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package foo;
use strict;
use warnings;
use constant DEAD_CODE => 0;
sub test
{
my $var;
if (DEAD_CODE) {
my $false_positive = 'xxx'; # <----- false positive
bar($false_positive);
$var = 'abc';
} else {
$var = 'def';
}
}
1;
The $false_positive variable is in dead code that is removed by inlining as can be seen with B::Deparse:
$ perl -MO=Deparse foo.pm
package foo;
sub BEGIN {
require strict;
do {
'strict'->import
};
}
use constant ('DEAD_CODE', 0);
sub test {
use warnings;
use strict;
my $var;
do {
$var = 'def'
};
}
use warnings;
use strict;
'???';
foo.pm syntax OK
But Test::Vars reports $false_positive as an unused variable:
$ TEST_VERBOSE=1 perl -Ilib -MTest::Vars -E 'vars_ok(shift)' foo.pm
# checking foo in foo.pm ...
# $false_positive is used once in &foo::test
not ok 1 - foo.pm
# Failed test 'foo.pm'
# at -e line 1.
# Tests were run but no plan was declared and done_testing() was not seen.
The text was updated successfully, but these errors were encountered:
Here is
foo.pm
:The
$false_positive
variable is in dead code that is removed by inlining as can be seen with B::Deparse:But
Test::Vars
reports$false_positive
as an unused variable:The text was updated successfully, but these errors were encountered: