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

People
Owner: Nobody in particular
Requestors: jdeighan [...] pcgus.com
Cc:
AdminCc:

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



From jdeighan [...] pcgus.com Tue Dec 14 10: 53:57 2010
X-Originalarrivaltime: 14 Dec 2010 15:53:30.0266 (UTC) FILETIME=[0DBF0FA0:01CB9BA7]
MIME-Version: 1.0
X-Spam-Status: No, score=-6.9 tagged_above=-99.9 required=10 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5] autolearn=ham
X-Spam-Flag: NO
content-type: text/plain; charset="utf-8"; format="flowed"
Message-ID: <4D0792FA.3050703 [...] pcgus.com>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Spam-Score: -6.9
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 50664241319 for <cpan-bug+Perl-Critic [...] hipster.bestpractical.com>; Tue, 14 Dec 2010 10:53:57 -0500 (EST)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2hR0HGXwUKss for <cpan-bug+Perl-Critic [...] hipster.bestpractical.com>; Tue, 14 Dec 2010 10:53:55 -0500 (EST)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 97CB1241317 for <bug-Perl-Critic [...] rt.cpan.org>; Tue, 14 Dec 2010 10:53:55 -0500 (EST)
Received: (qmail 27748 invoked by uid 103); 14 Dec 2010 15:53:55 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 14 Dec 2010 15:53:55 -0000
Received: from zixvpm01.pcgus.com (HELO zixvpm01.pcgus.com) (12.130.56.11) by 16.mx.develooper.com (qpsmtpd/0.80) with ESMTP; Tue, 14 Dec 2010 07:53:53 -0800
Received: from zixvpm01.pcgus.com (ZixVPM [127.0.0.1]) by Outbound.pcgus.com (Proprietary) with ESMTP id 25524158023 for <bug-Perl-Critic [...] rt.cpan.org>; Tue, 14 Dec 2010 10:53:50 -0500 (EST)
Received: from email.pcgus.com (email.pcgus.com [12.130.56.7]) by zixvpm01.pcgus.com (Proprietary) with ESMTP id 94C341D0002 for <bug-Perl-Critic [...] rt.cpan.org>; Tue, 14 Dec 2010 10:53:49 -0500 (EST)
Received: from [10.15.4.5] ([10.15.4.5]) by email.pcgus.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 14 Dec 2010 10:53:30 -0500
Delivered-To: cpan-bug+Perl-Critic [...] hipster.bestpractical.com
Subject: bug in Perl-Critic
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7
Return-Path: <jdeighan [...] pcgus.com>
X-RT-Mail-Extension: perl-critic
X-Original-To: cpan-bug+Perl-Critic [...] hipster.bestpractical.com
X-Spam-Check-BY: 16.mx.develooper.com
Date: Tue, 14 Dec 2010 10:53:30 -0500
X-Spam-Level:
To: bug-Perl-Critic [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: John Deighan <jdeighan [...] pcgus.com>
X-RT-Original-Encoding: ISO-8859-1
Content-Length: 1558
Download (untitled) / with headers
text/plain 1.5k
The following code (I've added line numbers): 1 # ---------------------------------------------------------- 2 3 use strict; 4 use warnings; 5 6 sub func { my($align) = @_; 7 8 my $hAttr = ($align eq 'center') ? { 'class' => 'treeroot', 9 'display' => 'table', 10 'left-margin' => 'auto', 11 'right-margin' => 'auto', 12 } 13 : ($align eq 'right') ? { 'class' => 'treeroot', 14 'display' => 'table', 15 'left-margin' => 0, 16 'right-margin' => 'auto', 17 } 18 : { 'class' => 'treeroot'}; 19 20 return $hAttr; 21 } # func() 22 23 # ---------------------------------------------------------- Results in the error: ---------------- C:\Scripts\test8.pl ---------------- Comma used to separate statements at line 8, column 38. See pages 68,71 of PBP. Comma used to separate statements at line 13, column 38. See pages 68,71 of PBP. -------------------------------------------------------------------------------- But, clearly, the commas are being used to separate keys and values in the definition of a hash. Here is some info about my setup: Perl-Critic: version 1.109 (I understand there's a 1.110, but it's not available via ppm) Perl: version 5.10.0 from ActiveState OS: Windows 2003 Server
MIME-Version: 1.0
In-Reply-To: <4D0792FA.3050703 [...] pcgus.com>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <4D0792FA.3050703 [...] pcgus.com>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-19311-1292344017-157.63904-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 2759
Download (untitled) / with headers
text/plain 2.6k
On Tue Dec 14 10:53:57 2010, jdeighan@pcgus.com wrote: Show quoted text
> The following code (I've added line numbers): > > > 1 # ---------------------------------------------------------- > 2 > 3 use strict; > 4 use warnings; > 5 > 6 sub func { my($align) = @_; > 7 > 8 my $hAttr = ($align eq 'center') ? { 'class' => 'treeroot', > 9 'display' => 'table', > 10 'left-margin' => 'auto', > 11 'right-margin' => 'auto', > 12 } > 13 : ($align eq 'right') ? { 'class' => 'treeroot', > 14 'display' => 'table', > 15 'left-margin' => 0, > 16 'right-margin' => 'auto', > 17 } > 18 : { 'class' => 'treeroot'}; > 19 > 20 return $hAttr; > 21 } # func() > 22 > 23 # ---------------------------------------------------------- > > Results in the error: > > ---------------- C:\Scripts\test8.pl ---------------- > Comma used to separate statements at line 8, column 38. See pages > 68,71 of PBP. > Comma used to separate statements at line 13, column 38. See pages > 68,71 of PBP. >
-------------------------------------------------------------------------------- Show quoted text
> > But, clearly, the commas are being used to separate keys and values in > the definition of a hash. > > Here is some info about my setup: > > Perl-Critic: version 1.109 (I understand there's a 1.110, but it's not > available via ppm) > Perl: version 5.10.0 from ActiveState > OS: Windows 2003 Server
Unfortunately, this bug is not in Perl::Critic proper, but is inherited from PPI, which Perl::Critic uses to do its parsing, and which thinks that your hash constructors are blocks. Equally unfortunately, this has proven to be an especially recalcitrant bug (or collection of bugs, maybe), since the way Perl disambiguates hash constructors from blocks is undocumented. So it's hard to know how to fix this without breaking something else. Perl does, however, provide a mechanism (which PPI understands) for forcing interpretation of a set of curly brackets: a unary plus ('+{ ... }') forces a hash constructor, and a semicolon inside ('{; ... }') forces a block, as documented in perlref. It's a shame to have to change your code to get PPI and Perl::Critic to interpret it correctly, but that or a '## no critic' annotation are the only short-term solutions I know of. Maybe one of the other developers knows something. There's no Perl::Critic 1.110 on CPAN either. There's a 1.110_001 (in preparation for 1.111), but that shows the same behavior :-(


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.