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

People
Owner: Nobody in particular
Requestors: PETDANCE [...] cpan.org
Cc:
AdminCc:

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



Subject: "open $fh,'<',$name || die" gets past InputOutput::RequireCheckedOpen
Consider this program: #!/usr/bin/perl use warnings; use strict; my $name = 'nonexistent-filename.txt'; open my $fh_one, '<', $name; close $fh_one; open my $fh_two, '<', $name || die; close $fh_two; The first open will get flagged by InputOutput::RequireCheckedOpen. The second open will NOT get flagged, even though the return value is not checked. Because of the order of operations, and "||" binding tighter than "or", the second open is the same as open my $fh_two, '<', ($name || die); This is a common problem with people interchanging "||" for "or" and not realizing the impact. Running code through B::Deparse makes this clear, too. $ cat or2 open $fh, '<', $name || die; open $fh, '<', $name or die; open $fh, '<', ($name || die); open $fh, '<', ($name or die); (open $fh, '<', $name) || die; (open $fh, '<', $name) or die; $ perl -MO=Deparse or2 open $fh, '<', $name || die; die unless open $fh, '<', $name; open $fh, '<', $name || die; open $fh, '<', $name || die; die unless open $fh, '<', $name; die unless open $fh, '<', $name; or2 syntax OK


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

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.