Skip to content

String#[]= [regexp, index] raises an IndexError when the index points to unmatched optional captures #2314

Merged
merged 2 commits into from Apr 26, 2013

2 participants

@kachick
Rubinius member
kachick commented Apr 26, 2013

ruby 1.8.7 (2012-10-12 patchlevel 371)
ruby 1.9.3p392 (2013-02-22 revision 39386)

str = "a b c"
str[/a (b) (Z)?/,  2] = "d" #=> IndexError: regexp group 2 not matched
str                         #=> "a b c"

rubinius 2.0.0.rc1 (1.8.7 aacddf7 yyyy-mm-dd JI)

str = "a b c"
str[/a (b) (Z)?/,  2] = "d" #=> ArgumentError: character index is negative
str                         #=> "a b c"

rubinius 2.0.0.rc1 (1.9.3 aacddf7 yyyy-mm-dd JI)

str = "a b c"
str[/a (b) (Z)?/,  2] = "d" #=> "d"
str                         #=> "da b c"
kachick added some commits Apr 27, 2013
@kachick kachick Add a spec for String#[]= [regexp, index]
When the index points to unmatched captures.
b0db32e
@kachick kachick Fix String#[]= [regexp, index]
When the index points to unmatched captures.
561fabb
@dbussink dbussink merged commit 5eef6e5 into rubinius:master Apr 26, 2013

1 check was pending

Details default The Travis build is in progress
@dbussink
Rubinius member

Thanks!

@dbussink
Rubinius member

BTW, we have an open commit policy with Rubinius so if you feel confident to push stuff yourself, feel free to do so!

@kachick
Rubinius member
kachick commented Apr 26, 2013

Thanks to merge!
And thank you for the suggestion.
The policy is so great :)

I want to push to rubinius/rubinius when i have confidence for the commits.
Could you add me to the organization?

@kachick kachick deleted the kachick:fix-string-element_set_with_regexp-index branch Apr 26, 2013
@dbussink
Rubinius member

Added :). Thanks for contributing :).

@kachick
Rubinius member
kachick commented Apr 26, 2013

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.