New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Str.rindex returns error messages with missing or incorrect information #5659
Comments
From @dogbert17# Tested with dogbert@dogbert-VirtualBox ~/.rakudobrew/moar-nom $ perl6 -v This is Rakudo # the first problem dogbert@dogbert-VirtualBox ~/.rakudobrew/moar-nom $ perl6 -e 'say Actually thrown at: # the position given *IS* out of range but the suggestion given, i.e. dogbert@dogbert-VirtualBox ~/.rakudobrew/moar-nom $ perl6 -e 'say # this also failed but this time we got no extra information, i.e. "Position See http://irclog.perlgeek.de/perl6/2016-09-10#i_13185974 /dogbert17 |
From @lizmatOddly enough, index() does *not* have this issue: $ 6 'say "1234".index("2", 4)’ Not sure that’s a bug either.
|
The RT System itself - Status changed from 'new' to 'open' |
From @dogbert17They 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)' Actually thrown at: -----Original Message----- Oddly enough, index() does *not* have this issue: $ 6 'say "1234".index("2", 4)’ Not sure that’s a bug either.
|
From @MasterDuke17On Mon Sep 12 13:56:24 2016, jan-olof.hendig@bredband.net wrote:
Roast has a test for index and rindex that implies the 1..4 range in this bug's example is correct. To expand on the inconsistency between index and rindex, "1234".index("", 5) and "1234".index("2", 5) both return Nil, and so does "1234".rindex("", 5), but "1234".rindex("2", 5) fails with "index start offset out of range". This inconsistency is passed through from nqp, where nqp::index("1234", "", 5) and nqp::index("1234", "2", 5) both return -1, but nqp::rindex("1234", "", 5) returns -1 and nqp::rindex("1234", "2", 5) fails with "index start offset out of range". And the real source of the inconsistency is in MoarVM like timotimo said in the chat log. MVM_string_index_from_end in src/string.ops.c has: but MVM_string_index has: What should the Perl 6 behavior be? Return Nil when it's a little bit out of range and a Failure if it's a lot out of range? Or return either Nil or Failure if it's at all out of range? |
From @MasterDuke17On Mon Sep 19 23:30:20 2016, ddgreen@gmail.com wrote:
Adding [@LARRY] per http://irclog.perlgeek.de/perl6-dev/2016-09-22#i_13254766 |
From @MasterDuke17On Thu Sep 22 04:39:30 2016, ddgreen@gmail.com wrote:
Adding comments from a conversation with TimToady (http://irclog.perlgeek.de/perl6/2016-09-26#i_13285140) 16:28 TimToady_ MasterDuke_: rindex is not symmetrical with index, since positions are measured from the start of the needle, not the end, so I'd say the rindex("1234","2",4) should fail indicating the correct range is 0..3, since the actual allowed range is not 0 .. 4 but rather 0 .. 4 - $needle.chars |
Migrated from rt.perl.org#129248 (status was 'open')
Searchable as RT129248$
The text was updated successfully, but these errors were encountered: