They do indeed behave somewhat inconsistently when the position is too high. Consistency, and the off by one error, returns when using -1 though.
dogbert@dogbert-VirtualBox ~/repos/doc $ perl6 -e 'say "1234".index("2", -1)' Position in index out of range. Is: -1, should be in 0..4 in block <unit> at -e line 1 Actually thrown at: in block <unit> at -e line 1 -----Original Message----- From: Elizabeth Mattijsen via RT [mailto:perl6-bugs-follo...@perl.org] Sent: den 11 september 2016 21:38 To: jan-olof.hen...@bredband.net Subject: Re: [perl #129248] [BUG] Str.rindex returns error messages with missing or incorrect information Oddly enough, index() does *not* have this issue: $ 6 'say "1234".index("2", 4)’ Nil Not sure that’s a bug either. > On 11 Sep 2016, at 16:58, Jan-Olof Hendig (via RT) > <perl6-bugs-follo...@perl.org> wrote: > > # New Ticket Created by Jan-Olof Hendig # Please include the string: > [perl #129248] # in the subject line of all future correspondence > about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=129248 > > > > # Tested with > > dogbert@dogbert-VirtualBox ~/.rakudobrew/moar-nom $ perl6 -v This is > Rakudo version 2016.08.1-155-gccecbfe built on MoarVM version > 2016.08-43-g3d04391 implementing Perl 6.c. > > # the first problem > > dogbert@dogbert-VirtualBox ~/.rakudobrew/moar-nom $ perl6 -e 'say > "1234".rindex("2", -1)' > Position in rindex out of range. Is: -1, should be in 0..4 in block > <unit> at -e line 1 > > Actually thrown at: > in block <unit> at -e line 1 > > # the position given *IS* out of range but the suggestion given, i.e. > "should be in 0..4" is incorrect since the string only contains four > chars # let us test the suggestion and use 4 as the position > > dogbert@dogbert-VirtualBox ~/.rakudobrew/moar-nom $ perl6 -e 'say > "1234".rindex("2", 4)' > index start offset out of range > in block <unit> at -e line 1 > > # this also failed but this time we got no extra information, i.e. > "Position in rindex out of range. Bla bla" > # according to timo this could possibly point to a problem in MoarVM > > See http://irclog.perlgeek.de/perl6/2016-09-10#i_13185974 > > /dogbert17 > >