From: Vincent Pit Date: Fri, 8 Aug 2008 21:20:49 +0000 (+0200) Subject: Test for definedness of returned values because 0 is really { 0 => 1 } in our context X-Git-Tag: v0.03~4 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FSub-Nary.git;a=commitdiff_plain;h=02510517a867d6f89d6dac825672e183e075e97e Test for definedness of returned values because 0 is really { 0 => 1 } in our context --- diff --git a/lib/Sub/Nary.pm b/lib/Sub/Nary.pm index 14b8822..52a3f84 100644 --- a/lib/Sub/Nary.pm +++ b/lib/Sub/Nary.pm @@ -262,7 +262,7 @@ sub inspect { my $op = $op->first; my ($r1, $l1) = $self->inspect($op); - return $r1, $l1 if $r1 and zero $l1; + return $r1, $l1 if defined $r1 and zero $l1; my $c = count $l1; $op = $op->sibling; @@ -551,11 +551,12 @@ sub pp_grepwhile { $op = $op->first->sibling; my ($r2, $l2) = $self->inspect($op->sibling); - return $r2, $l2 if $r2 and zero $l2; + return $r2, $l2 if defined $r2 and zero $l2; my $c2 = count $l2; # First one to happen my ($r1, $l1) = $self->inspect($op); - return (add $r2, scale $c2, $r1), undef if $r1 and zero $l1 and not zero $l2; + return (add $r2, scale $c2, $r1), undef if defined $r1 and zero $l1 + and not zero $l2; diag Dumper [ [ $r1, $l1 ], [ $r2, $l2 ] ] if $DEBUG; my $c1 = count $l1; @@ -575,11 +576,12 @@ sub pp_mapwhile { $op = $op->first->sibling; my ($r2, $l2) = $self->inspect($op->sibling); - return $r2, $l2 if $r2 and zero $l2; + return $r2, $l2 if defined $r2 and zero $l2; my $c2 = count $l2; # First one to happen my ($r1, $l1) = $self->inspect($op); - return (add $r2, scale $c2, $r1), undef if $r1 and zero $l1 and not zero $l2; + return (add $r2, scale $c2, $r1), undef if defined $r1 and zero $l1 + and not zero $l2; diag Dumper [ [ $r1, $l1 ], [ $r2, $l2 ] ] if $DEBUG; my $c1 = count $l1;