Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the PPI CPAN distribution.

Report information
The Basics
Id: 52259
Status: resolved
Priority: 0/
Queue: PPI

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

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



Subject: hash keys called "package" treated as a package declaration.
Download (untitled) / with headers
text/plain 456b
I ran into a couple of bugs as a side effect of doing { package => 'foo' } While its perfectly legitimate peel code, perlcritic confuses it. I then tried disambiguating it with +{ at the front, and the problem went from bad to worse. Attached is a test script ( also visible here: http://gist.github.com/244947 ) that exemplifies the problems I encountered. Current work around: Quote the hash key explicitly, don't use + to disambiguate.
Subject: duplicatePackage.pl
Download duplicatePackage.pl
text/x-perl 1.5k
package duplicatePackage; # $Id:$ use strict; use warnings; use Perl::Critic; use Test::More; my @strings = ( q| { package => "", }|, # 0 => Fails q| +{ package => "", }|, # 1 => Fails q| { 'package' => "", }|, # 2 q| +{ 'package' => "", }|, # 3 => Fails q| { 'package' , "", }|, # 4 q| +{ 'package' , "", }|, # 5 => Fails. ); sub generate_code { my ( $package, $signature ) = @_; return sprintf <<'EOF', $package, $signature; package %s; use strict; use warnings; use Data::Dumper qw( Dumper ); sub subx { my $foo = [ {}, %s ,]; return $foo; } subx(); 1; EOF } my $testid = 0; sub generate_test { my $id = $testid++; my $signature = shift; my $package = "Test::Package::_${id}_"; my $code = generate_code( $package, $signature ); return { id => $id, package => $package, code => $code, signature => $signature, }; } my $critic = Perl::Critic->new( -include => [ 'ProhibitCommaSeparatedStatements', 'ProhibitMultiplePackages' ] ); for my $string ( @strings ){ my $testdata = generate_test( $string ); undef $@; ok( eval $testdata->{code} , 'Evaling the codeblock for test ' . $testdata->{id} . 'works' ); ok( !$@ , 'No Eval errors for ' . $testdata->{id} ); is_deeply( $testdata->{package}->subx() , [ {}, {'package', '' }], 'Data structure is solid for ' . $testdata->{id} ); my @violations = $critic->critique( \$testdata->{code}); ok( !@violations , 'Violations is empty for ' . $testdata->{id} ) or diag explain { test => $testdata, violations => "@violations" }; } 1;
Subject: Re: [rt.cpan.org #52259] hash keys called "package" treated as a package declaration.
Date: Sun, 29 Nov 2009 12:56:11 -0600
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Download (untitled) / with headers
text/plain 110b
This has nothing to do with Perl::Critic and everything to do with PPI. I've switched this to the PPI queue.
Subject: Re: [rt.cpan.org #52259] hash keys called "package" treated as a package declaration.
Date: Sun, 29 Nov 2009 13:34:13 -0600
To: bug-PPI [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Download (untitled) / with headers
text/plain 246b
Elliot Shank wrote: Show quoted text
> This has nothing to do with Perl::Critic and everything to do with PPI. > I've switched this to the PPI queue.
And there's now a failing test in PPI itself: http://fisheye2.atlassian.com/changelog/cpan/trunk/PPI?cs=10313
This should be fixed now


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.