Project

General

Profile

Actions

Bug #20421

open

String#index and String#byteindex don't clear `$~` when offset > size (or bytesize)

Added by andrykonchin (Andrew Konchin) 19 days ago. Updated 19 days ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:117494]

Description

When String#index and String#byteindex are called with Regexp and offset they clear $~ (that contains result of the last Regexp matching) when offset < -size. But they don't clear $~ when offset > size what seems inconsistent:

"a".index(/a/)
p $~ # => #<MatchData "a">

string = "blablabla"
string.index(/bla/, string.length + 1)
p $~ # => #<MatchData "a">
Actions #1

Updated by andrykonchin (Andrew Konchin) 19 days ago

  • Description updated (diff)
Actions

Also available in: Atom PDF

Like0
Like0