diff --git a/lib/PPI/Normal.pm b/lib/PPI/Normal.pm index fd01413d..920dc533 100644 --- a/lib/PPI/Normal.pm +++ b/lib/PPI/Normal.pm @@ -86,7 +86,7 @@ sub register { } # Has it already been added? - if ( List::Util::any { $_ eq $function } ) { + if ( List::Util::any { $_ eq $function } map @{$_}, values %LAYER ) { return 1; } diff --git a/t/09_normal.t b/t/09_normal.t index 7f587b63..c5929110 100644 --- a/t/09_normal.t +++ b/t/09_normal.t @@ -59,6 +59,5 @@ NO_DOUBLE_REG: { is $PPI::Normal::LAYER{2}[-1], "main::just_a_test_sub", "and find subs at right layer"; my $size = @{ $PPI::Normal::LAYER{2} }; ok( PPI::Normal->register( "main::just_a_test_sub", 2 ), "can add subs again" ); - local $TODO = 'prevent duplicate registrations of normals'; is scalar @{ $PPI::Normal::LAYER{2} }, $size, "but sub isn't added twice"; }