Issue #9581 has been reported by Tsuyoshi Sawada.

----------------------------------------
Bug #9581: `=~` defined on a subclass of `String` is sometimes ignored, and `String#=~` is called instead
https://bugs.ruby-lang.org/issues/9581

* Author: Tsuyoshi Sawada
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: 2.1.0p0
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
As is reported on StackOverflow (http://stackoverflow.com/questions/22103018) by Gabriel, overridden `=~` on a subclass of `String` is sometimes ignored, and the original `String#=~` is called. Particularly, when we have:

    class MyString < String
      def =~ re; :foo end
    end
    s = MyString.new("abc")

these give the correct result:

    r = /abc/; s =~ r   # => :foo
    s.send(:=~, r)      # => :foo
    s.send(:=~, /abc/)  # => :foo

but in this case, `MyString#=~` is ignored, and `String#=~` is called instead:

    s =~ /abc/          # => 0
    



-- 
http://bugs.ruby-lang.org/