diff --git a/lib/PPI/Node.pm b/lib/PPI/Node.pm index 2b4f5ebe..bb4f76b7 100644 --- a/lib/PPI/Node.pm +++ b/lib/PPI/Node.pm @@ -512,7 +512,7 @@ sub remove_child { my $p = List::MoreUtils::firstidx { refaddr $_ == $key } @{$self->{children}}; - return undef unless defined $p; + return undef if $p == -1; # Splice it out, and remove the child's parent entry splice( @{$self->{children}}, $p, 1 ); diff --git a/t/ppi_node.t b/t/ppi_node.t index 12f26f23..cc14c6b6 100644 --- a/t/ppi_node.t +++ b/t/ppi_node.t @@ -42,6 +42,5 @@ REMOVE_CHILD: { my $del1 = $node->child(7); is $node->remove_child($del1), $del1; my $fake = bless { content => 3 }, "PPI::Token::Number"; - local $TODO = "firstidx is mis-used here"; is $node->remove_child($fake), undef; }