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: 54764
Status: new
Priority: 0/
Queue: Perl-Critic

Owner: Nobody in particular
Requestors: EDAVIS [...]

Bug Information
Severity: Normal
Broken in: 1.105
Fixed in: (no value)

Subject: ErrorHandling::RequireCheckingReturnValueOfEval false positive on 'return eval'
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 823
Download (untitled) / with headers
text/plain 823b
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.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to