Skip to content

Commit

Permalink
fix check of return value of firstidx (-1 on not found, instead of un…
Browse files Browse the repository at this point in the history
…def)
  • Loading branch information
wchristian committed Jan 20, 2017
1 parent d5f0990 commit 07cd2bb
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 1 addition & 1 deletion lib/PPI/Node.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
1 change: 0 additions & 1 deletion t/ppi_node.t
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 07cd2bb

Please sign in to comment.