Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different Regexp behavior from MRI #2905

nirvdrum opened this Issue May 1, 2015 · 3 comments


None yet
2 participants
Copy link

commented May 1, 2015

It looks like somewhere between 1.9.3 and 2.2.2, MRI changed its behavior around overriding String#=~. JRuby special-cases this behavior in:

It looks like the correct behavior is to always do a dispatch to =~ to pick up any overrides.


MRI 2.2.2:

> ruby -v -e 'class String; def =~(regexp); :weird_value; end; end; p "a" =~ /./'
-e:1: warning: method redefined; discarding old =~


> bin/jruby -v -e 'class String; def =~(regexp); :weird_value; end; end; p "a" =~ /./'
jruby (2.2.2) 2015-04-30 ef1fc91 Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b14 +jit [linux-amd64]

@nirvdrum nirvdrum added the JRuby 9000 label May 1, 2015


This comment has been minimized.

Copy link
Contributor Author

commented May 1, 2015

Interestingly, MRI 1.9.3 prints the same warning, but then prints the match index.


This comment has been minimized.

Copy link

commented May 4, 2015

Might just be simplest to make all matches dyncall; caching and indy will make up the difference between this and the direct call.


This comment has been minimized.

Copy link

commented May 5, 2015

Oops, forgot to tag the commit. This should be fixed on master in 8d67e58.

@headius headius closed this May 5, 2015

@headius headius added this to the JRuby milestone May 5, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.