From: merch-redmine@... Date: 2020-06-01T17:35:38+00:00 Subject: [ruby-core:98611] [Ruby master Bug#14671] Refining Module#refine itself introduces strange state Issue #14671 has been updated by jeremyevans0 (Jeremy Evans). Status changed from Open to Rejected This is because Class undefs `refine`, and the refinement for Module is after the lookup chain for Class. Your code works fine if you call `refine` on a Module and not a Class, or if you remove the `undef` from Class. Ruby does not support directly removing an `undef` through `remove_method`, but you can override the method and remove the overridden method. This code: ```ruby using Module.new { refine Module do def refine *; puts self end public :refine end } Enumerable.refine Class.define_method(:refine){} Class.remove_method(:refine) Object.refine ``` prints: ``` Enumerable Object ``` Your code also works if you refine Class instead of Module. ---------------------------------------- Bug #14671: Refining Module#refine itself introduces strange state https://bugs.ruby-lang.org/issues/14671#change-85933 * Author: shyouhei (Shyouhei Urabe) * Status: Rejected * Priority: Normal * ruby -v: ruby 2.6.0dev (2018-04-09 trunk 63122) [x86_64-darwin15] * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- ```ruby using Module.new { refine Module do def refine *; puts self end public :refine end } Object.refine # => NoMethodError ``` It is possible to refine Module#refine, but there seems to be no way to call it. -- https://bugs.ruby-lang.org/ Unsubscribe: