Subject: | ErrorHandling::RequireCheckingReturnValueOfEval false positive on 'return eval' |
This example program checks the return value of eval, or at least uses it:
#!/usr/bin/perl
use warnings;
use strict;
sub x {
return eval '1 + 1';
}
x or die;
However 'perlcritic --single-policy
ErrorHandling::RequireCheckingReturnValueOfEval' flags it:
Return value of eval not tested at line 5, column 12. You can't depend
upon the value of $@/$EVAL_ERROR to tell whether an eval failed.
(Severity: 3)
Now, this is a string-form eval, which has a separate policy telling you
not to use it. But if the programmer decides to use that construct,
code like the above is reasonable enough.
The policy should recognize 'return eval "string"' and 'return eval {
... }' as doing something with the return value of eval (even though
it's up to the subroutine's caller to check it) and so should not warn
in these cases.