Skip to content

Commit

Permalink
Replace several cheat returns of Mu with actual returns of fail messa…
Browse files Browse the repository at this point in the history
…ges.
  • Loading branch information
colomon committed Dec 10, 2009
1 parent dc293ee commit 920640f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/core/Any-str.pm
Expand Up @@ -87,8 +87,7 @@ augment class Any {
}

my $result = pir::index__ISSi(self, $substring, $pos);
# fail("Substring '$substring' not found in '{self}'") if ($result < 0);
if $result < 0 { return Mu; } # no StrPos yet
fail("Substring '$substring' not found in '{self}'") if $result < 0;
return $result;

# also used to be a the following error message, but the condition
Expand All @@ -104,8 +103,7 @@ augment class Any {
# }
#
# my $result = pir::reverse_index__ISSi(self, $substring, $pos);
# # fail("Substring '$substring' not found in '{self}'") if ($result < 0);
# if $result < 0 { return Mu; } # no StrPos yet
# fail("Substring '$substring' not found in '{self}'") if $result < 0;
# return $result;
#
# # also used to be a the following error message, but the condition
Expand Down
8 changes: 4 additions & 4 deletions src/core/Array.pm
Expand Up @@ -27,14 +27,14 @@ augment class Array {
self;
}

#CHEAT: Should return fail rather than Mu
our multi method pop() {
self.elems > 0 ?? pir::pop__PP($!values) !! Mu;
self.elems > 0 ?? pir::pop__PP($!values)
!! fail('Undefined value popped from empty array');
}

#CHEAT: Should return fail rather than Mu
our multi method shift() {
self.elems > 0 ?? pir::shift__PP($!values) !! Mu;
self.elems > 0 ?? pir::shift__PP($!values)
!! fail('Undefined value shifted from empty array');
}
}

Expand Down

0 comments on commit 920640f

Please sign in to comment.