From: usa@... Date: 2015-07-03T08:56:00+00:00 Subject: [ruby-core:69853] [Ruby trunk - Bug #11117] When you refine String with to_regexp, then it breaks Regexp.try_convert even when the refinement is not used Issue #11117 has been updated by Usaku NAKAMURA. Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED to 2.0.0: REQUIRED, 2.1: DONE, 2.2: REQUIRED ruby_2_1 r51119 merged revision(s) 50430,50440. ---------------------------------------- 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-53254 * Author: Jakub Jirutka * Status: Closed * Priority: Normal * Assignee: * ruby -v: 2.2.2p95 * Backport: 2.0.0: REQUIRED, 2.1: DONE, 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 `
' ~~~ 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/