Skip to content

Commit 46e810f

Browse files
committed
fix check of return value of firstidx (-1 on not found, instead of undef)
1 parent 9f91982 commit 46e810f

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

lib/PPI/Node.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ sub remove_child {
512512
my $p = List::MoreUtils::firstidx {
513513
refaddr $_ == $key
514514
} @{$self->{children}};
515-
return undef unless defined $p;
515+
return undef if $p == -1;
516516

517517
# Splice it out, and remove the child's parent entry
518518
splice( @{$self->{children}}, $p, 1 );

t/ppi_node.t

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,5 @@ REMOVE_CHILD: {
4242
my $del1 = $node->child(7);
4343
is $node->remove_child($del1), $del1;
4444
my $fake = bless { content => 3 }, "PPI::Token::Number";
45-
local $TODO = "firstidx is mis-used here";
4645
is $node->remove_child($fake), undef;
4746
}

0 commit comments

Comments
 (0)