Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Perl-Critic-StricterSubs CPAN distribution.

Report information
The Basics
Id: 97363
Status: open
Priority: 0/
Queue: Perl-Critic-StricterSubs

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

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



Subject: Subroutines::ProhibitCallsToUndeclaredSubs thinks 0xA0 is calling the sub 'A0'
For some reason:

   my $x = 0xA0

Fails under the guise of it being apparently parsed as:

    '0' x ( A0() )

At least, thats the best I think I can imagine based on what I'm seeing.

Either way, here is an attached test that replicates the error.
Subject: hex-isnt-sub.t
#!/usr/bin/env perl # FILENAME: test.pl # CREATED: 07/21/14 02:49:11 by Kent Fredric (kentnl) <kentfredric@gmail.com> # ABSTRACT: Test critic policy for 0xA0 use strict; use warnings; use utf8; use Test::More; use Perl::Critic::TestUtils qw(pcritique pcritique_with_violations); local $@; my $x; my $fatal = 1; my $code = <<'EOF'; $x = 0xA0; $fatal = 0; EOF eval $code; is( $fatal, 0, 'Given code has no errors' ) or diag explain $@; is( $x, 160, 'X is expected value' ); my @violations = pcritique_with_violations( 'Subroutines::ProhibitCallsToUndeclaredSubs', \$code ); is( scalar @violations, 0, "No violations" ) or diag explain \@violations;
Perl::Critic relies on PPI to do its parsing, and this looks to me like a PPI error. That is unfortunate since Adam Kennedy has moved on from Perl and nobody seems to have picked up the maintenance of PPI. An unpalatable workaround is to use all lower case in the hex numbers, as PPI seems to parse that correctly: $ # This is the parse we want $ ppidump '0xa0' PPI::Document PPI::Statement [ 1, 1, 1 ] PPI::Token::Number::Hex '0xa0' $ # All the following parses are incorrect $ ppidump '0xA0' PPI::Document PPI::Statement [ 1, 1, 1 ] PPI::Token::Number::Hex '0x' [ 1, 3, 3 ] PPI::Token::Word 'A0' $ ppidump '0XA0' PPI::Document PPI::Statement [ 1, 1, 1 ] PPI::Token::Number '0' [ 1, 2, 2 ] PPI::Token::Word 'XA0' $ ppidump '0Xa0' PPI::Document PPI::Statement [ 1, 1, 1 ] PPI::Token::Number '0' [ 1, 2, 2 ] PPI::Token::Word 'Xa0'
Subject: Re: [rt.cpan.org #97363] Subroutines::ProhibitCallsToUndeclaredSubs thinks 0xA0 is calling the sub 'A0'
Date: Mon, 21 Jul 2014 08:48:47 -0700
To: bug-Perl-Critic-StricterSubs [...] rt.cpan.org
From: "Thalhammer, Jeffrey Ryan" <jeff [...] imaginative-software.com>
I believe Christian Walde has taken over maintenance of PPI. There is a new-ish development release on CPAN that has several bug fixes. We should check that. I'm at a conference this week so I won't get to it for a few days. On Jul 21, 2014 6:48 AM, "Tom Wyant via RT" < bug-Perl-Critic-StricterSubs@rt.cpan.org> wrote: Show quoted text
> Queue: Perl-Critic-StricterSubs > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=97363 > > > Perl::Critic relies on PPI to do its parsing, and this looks to me like a > PPI error. That is unfortunate since Adam Kennedy has moved on from Perl > and nobody seems to have picked up the maintenance of PPI. An unpalatable > workaround is to use all lower case in the hex numbers, as PPI seems to > parse that correctly: > > $ # This is the parse we want > $ ppidump '0xa0' > PPI::Document > PPI::Statement > [ 1, 1, 1 ] PPI::Token::Number::Hex '0xa0' > $ # All the following parses are incorrect > $ ppidump '0xA0' > PPI::Document > PPI::Statement > [ 1, 1, 1 ] PPI::Token::Number::Hex '0x' > [ 1, 3, 3 ] PPI::Token::Word 'A0' > $ ppidump '0XA0' > PPI::Document > PPI::Statement > [ 1, 1, 1 ] PPI::Token::Number '0' > [ 1, 2, 2 ] PPI::Token::Word 'XA0' > $ ppidump '0Xa0' > PPI::Document > PPI::Statement > [ 1, 1, 1 ] PPI::Token::Number '0' > [ 1, 2, 2 ] PPI::Token::Word 'Xa0' > > >
I can indeed confirm that with the newest DEV version of PPI https://metacpan.org/release/MITHALDU/PPI-1.216_01

That this test passes.

Likewise, this is what App::PPI::Dumper does:

echo '0xa0' | ppi_dumper /dev/stdin
PPI::Document
  PPI::Statement
    PPI::Token::Number::Hex      '0xa0'
  PPI::Token::Whitespace      '\n'

echo '0xA0' | ppi_dumper /dev/stdin
PPI::Document
  PPI::Statement
    PPI::Token::Number::Hex      '0xA0'
  PPI::Token::Whitespace      '\n'

echo '0XA0' | ppi_dumper /dev/stdin
PPI::Document
  PPI::Statement
    PPI::Token::Number::Hex      '0XA0'
  PPI::Token::Whitespace      '\n'