A run I did of an older Perl::Critic (1.082) with the current version of
PPI exposed a bug in the code that warns about the deprecated
PPI::Structure::ForLoop element. Hitting this section of the code
caused a fatal error when an attempt was made to call the "type" method
(nonexistent) for PPI::Structure::List.
The attached patch cured the problem for me. I also brought in Carp so
that the warning would give more useful context.
Subject: | forloop-deprecation-fix.patch |
--- List.pm.orig 2009-08-18 17:34:23.000000000 -0700
+++ List.pm 2009-08-18 17:42:25.000000000 -0700
@@ -38,6 +38,9 @@
use strict;
use PPI::Structure ();
+use Carp;
+$Carp::CarpLevel = 1;
+
use vars qw{$VERSION @ISA};
BEGIN {
$VERSION = '1.206';
@@ -52,10 +55,10 @@
if (
$_[0]->parent->isa('PPI::Statement::Compound')
and
- $_[0]->type =~ /^for/
+ $_[0]->parent->type =~ /^for/
) {
unless ( $has_warned ) {
- warn("PPI::Structure::ForLoop has been deprecated");
+ carp("PPI::Structure::ForLoop has been deprecated");
$has_warned = 1;
}
return 1;