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

People
Owner: Nobody in particular
Requestors: user42 [...] zip.com.au
Cc:
AdminCc:

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



Subject: Utils precedence_of() on filetest -f etc
Date: Fri, 25 Jul 2008 11:04:26 +1000
To: bug-Perl-Critic [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
It might be good if precedence_of() in Perl::Critic::Utils supported the filetest operators like -f, so it has an answer for basically anything ppi parses as PPI::Token::Operator. use strict; use warnings; use Perl::Critic::Utils qw(precedence_of); print precedence_of('-f')//'undef',"\n"; => "undef" (I thought I wanted such a precedence for a policy, but ended up only caring about binary operators, not unaries. I notice PPI::Token::Operator is not created for pseudo-operators like "sin" and "cos". Dunno if precedence_of could answer about them too ... perhaps not.)
Subject: Re: [rt.cpan.org #37915] Utils precedence_of() on filetest -f etc
Date: Thu, 24 Jul 2008 18:36:53 -0700
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Kevin Ryde via RT wrote: Show quoted text
> I notice PPI::Token::Operator is not created for pseudo-operators > like "sin" and "cos". Dunno if precedence_of could answer about them > too ... perhaps not.)
"sin" etc. are builtins, not operators. perlfunc vs. perlop.
I've added all the filetest operators in revision 3067. Note this caveat from perlop: Regarding precedence, the filetest operators, like "−f", "−M", etc. are treated like named unary operators, but they don’t follow this functional parenthesis rule. That means, for example, that "−f($file).".bak"" is equivalent to "−f "$file.bak"". Technically speaking, we could also add the named unary operators to the precedence_of() function, but PPI presently parses those as barewords, not operators. So I'm going to ignore them for now.
This has been completed and released in Perl-Critic-1.097_002. http://search.cpan.org/~elliotjs/Perl-Critic-1.097_002 Thank you for submitting this ticket.