Project

General

Profile

Actions

Bug #19746

closed

`String#index` with regexp and too large offset doesn't clear `$~`

Added by nobu (Nobuyoshi Nakada) 10 months ago. Updated 10 months ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:114031]

Description

/./ =~ "a"
p "x".index(/0/, 4) #=> nil
p $~ #=> #<MatchData "a">

while rindex does.

/./ =~ "a"
p "x".rindex(/0/, 4) #=> nil
p $~ #=> nil

It seems since 1.9.

Actions #1

Updated by nobu (Nobuyoshi Nakada) 10 months ago

  • Status changed from Open to Closed

Applied in changeset git|0cbfeb8210cd177bee95c512834c483daec36f74.


[Bug #19746] String#index with regexp should clear $~ unless matched

Updated by nagachika (Tomoyuki Chikanaga) 10 months ago

  • Backport changed from 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED to 3.0: REQUIRED, 3.1: REQUIRED, 3.2: WONTFIX

I cannot confident that there's no existing application depends on the current behavior.
I don't backport the changeset.

Actions

Also available in: Atom PDF

Like1
Like0Like0