Subject: | Unhandled type: REGEXP at ...Devel/Cycle.pm line 107 under Perl 5.12.0. |
Under Perl 5.12.0:
$ perl -MDevel::Cycle -e 'my $foo = qr{bar}smx; find_cycle($foo)'
Unhandled type: REGEXP at
/usr/local/perl/5.12.0/lib/site_perl/5.12.0/Devel/Cycle.pm line 107.
This appears to be because regular expressions have become first-class
objects under 5.12, so UNIVERSAL::isa($thingy,'SCALAR'), which was true
under 5.10 when $thingy contained a reference to a regexp, is false
under 5.12.
The attached patches against 1.11 restore the 5.10 behavior under 5.12,
by having _get_type() return 'SCALAR' when
UNIVERSAL::isa($thingy,'Regexp') is true, and test the handling of
regexps. The patches test without reporting any errors under both 5.10.1
and 5.12.0
Subject: | Devel-Cycle-pm.patch |
--- lib/Devel/Cycle.old 2009-08-24 08:54:45.000000000 -0400
+++ lib/Devel/Cycle.pm 2010-04-16 20:53:30.000000000 -0400
@@ -215,7 +215,7 @@
sub _get_type {
my $thingy = shift;
return unless ref $thingy;
- return 'SCALAR' if UNIVERSAL::isa($thingy,'SCALAR') || UNIVERSAL::isa($thingy,'REF');
+ return 'SCALAR' if UNIVERSAL::isa($thingy,'SCALAR') || UNIVERSAL::isa($thingy,'REF') || UNIVERSAL::isa($thingy,'Regexp');
return 'ARRAY' if UNIVERSAL::isa($thingy,'ARRAY');
return 'HASH' if UNIVERSAL::isa($thingy,'HASH');
return 'CODE' if UNIVERSAL::isa($thingy,'CODE');
Subject: | Devel-Cycle-t.patch |
--- t/Devel-Cycle.old 2008-07-08 21:26:35.000000000 -0400
+++ t/Devel-Cycle.t 2010-04-16 20:39:04.000000000 -0400
@@ -5,7 +5,7 @@
# change 'tests => 1' to 'tests => last_test_to_print';
-use Test::More tests => 12;
+use Test::More tests => 13;
use Scalar::Util qw(weaken isweak);
BEGIN { use_ok('Devel::Cycle') };
@@ -87,6 +87,7 @@
}
{
+ no warnings qw{ once };
*FOOBAR = *FOOBAR if 0; # cease -w
my $test2 = { glob => \*FOOBAR };
@@ -101,6 +102,15 @@
is("@warnings", "", "Warn only once");
}
+{
+ my $test_re = qr{foo}xms;
+
+ my @warnings;
+ local $SIG{__WARN__} = sub { push @warnings, @_ };
+ find_cycle($test_re);
+ ok( !@warnings, 'No warnings on Regex' );
+}
+
package foo;
use overload q("") => sub{ return 1 }; # show false alarm