JRuby somehow passes class extensions to submatches of Regexp matches; MRI does
not.
------------------------------------------------------------------------------------
Key: JRUBY-4881
URL: http://jira.codehaus.org/browse/JRUBY-4881
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.5.1, JRuby 1.5
Environment: OSX 10.6.3, comparison to stock OSX ruby.
Reporter: bob mcwhirter
Priority: Blocker
Attachments: extend_regexp.rb
If a String-like class is extended with a module, and subsequently matched with
a regexp, the sub-matches are not true strings, but rather also extend the
module mixed into the original string.
MRI does not apply input extensions on to the sub-match. JRuby does. This
breaks some interactions with rest-client gem, REXML, and Deltacloud-client.
All functions correctly under MRI.
This issue confirmed with 1.5.0 and 1.5.1.
The following demonstrates the issue. extend_regexp.rb included as attachment.
leonard:ctjr bob$ cat extend_regexp.rb
module Yeller
def holler()
"hey, look"
end
end
str = "one_two"
str.extend( Yeller )
puts "str hollers: #{str.holler}"
if ( str =~ /(one)_(two)/ )
puts "$1 hollers: #{$1.holler}"
puts "$2 hollers: #{$2.holler}"
end
leonard:ctjr bob$ ruby extend_regexp.rb
str hollers: hey, look
extend_regexp.rb:14: undefined method `holler' for "one":String (NoMethodError)
leonard:ctjr bob$ jruby extend_regexp.rb
str hollers: hey, look
$1 hollers: hey, look
$2 hollers: hey, look
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email