Skip to content

Commit

Permalink
Make Str.pred|succ handle subclasses of Str properly
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Apr 7, 2021
1 parent f4bfeea commit 813d4f1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/core.c/Str.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -767,13 +767,21 @@ my class Str does Stringy { # declared in BOOTSTRAP

method pred(Str:D: --> Str:D) {
(my int $chars = Rakudo::Internals.POSSIBLE-MAGIC-CHARS(self))
?? Rakudo::Internals.PRED(self,$chars - 1)
?? nqp::istype(
(my $pred := Rakudo::Internals.PRED(self,$chars - 1)),
Failure
) ?? $pred
!! nqp::box_s($pred,self)
!! self
}

method succ(Str:D: --> Str:D) {
(my int $chars = Rakudo::Internals.POSSIBLE-MAGIC-CHARS(self))
?? Rakudo::Internals.SUCC(self,$chars - 1)
?? nqp::istype(
(my $succ := Rakudo::Internals.SUCC(self,$chars - 1)),
Failure
) ?? $succ
!! nqp::box_s($succ,self)
!! self
}

Expand Down

0 comments on commit 813d4f1

Please sign in to comment.