rubinius/rubinius — pull request #2781 by pH14 (2013-11-14 01:33:25+00:00)
Title: Adding spec for backreferences to keep matched string's class

If a subclassed String is matched with a Regexp, the resulting [$`, $', $+, $&, $1...9] backreferences are of type String, not the original class. The matches in the $~ MatchData are correct.

A simple example illustrating this behavior compared to mri 2.0.0 can be found here: https://gist.github.com/pH14/7459516

I realize that subclassing String is typically dangerous territory. I bumped into this issue while exploring label propagation, as mentioned in the related pull request: https://github.com/rubinius/rubinius/pull/2763