Issue #11117 has been updated by Nobuyoshi Nakada. Priority changed from High to Normal Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED ---------------------------------------- Bug #11117: When you refine String with to_regexp, then it breaks Regexp.try_convert even when the refinement is not used https://bugs.ruby-lang.org/issues/11117#change-52342 * Author: Jakub Jirutka * Status: Closed * Priority: Normal * Assignee: * ruby -v: 2.2.2p95 * Backport: 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED ---------------------------------------- I”Ēve run into a very strange bug with refinements. Let me show you: ~~~ruby module Ref refine String do def to_regexp end end end Regexp.try_convert('foo') # or Regexp.union('foo', 'bar') ~~~ ~~~ bug.rb:8:in `try_convert': undefined method `to_regexp' for "foo":String (NoMethodError) from test.rb:8:in `<main>' ~~~ Note that the refinement is not used (_using_), only declared, and yet it has affected behaviour of the refined class! This problem occurs only when the method is named `to_string`. It seems that there”Ēs some serious scoping issue with refinements. I”Ēve reproduced this issue on MRI 2.2.2p95, 2.1.5p273, and 2.0.0p598. -- https://bugs.ruby-lang.org/