CC: | Heiko <heiko [...] hexco.de> |
Subject: | ProhibitCommaSeparatedValues doesn't handle hash dereferences. |
Date: | Sun, 09 Mar 2008 16:47:59 -0500 |
To: | bug-Perl-Critic [...] rt.cpan.org |
From: | Elliot Shank <perl [...] galumph.com> |
ValuesAndExpressions::ProhibitCommaSeparatedValues gives:
Comma used to separate statements at line 10, column 18. See pages 68,71 of PBP. (Severity: 4)
on this code:
my $href = { '1' => undef, '2' => undef };
func( @{ $href }{'1', '2'} );
sub func
{
}
The solution in the patch is to detect the block context.
--- ProhibitCommaSeparatedStatements.pm.org 2008-02-25 23:06:18.718750000 +0100
+++ ProhibitCommaSeparatedStatements.pm.new 2008-02-23 23:20:20.265625000 +0100
@@ -42,7 +42,7 @@
# Now, if PPI hasn't introduced any new PPI::Statement subclasses, we've
# got an element who's class really is PPI::Statement.
- return if _is_parent_a_constructor_or_list($elem);
+ return if _is_parent_a_constructor_or_list_or_block($elem);
return if _is_parent_a_foreach_loop($elem);
foreach my $child ( $elem->schildren() ) {
@@ -58,7 +58,7 @@
return;
}
-sub _is_parent_a_constructor_or_list {
+sub _is_parent_a_constructor_or_list_or_block {
my $elem = shift;
my $parent = $elem->parent();
@@ -68,6 +68,7 @@
return (
$parent->isa('PPI::Structure::Constructor')
or $parent->isa('PPI::Structure::List')
+ or $parent->isa('PPI::Structure::Block')
);
}