From: "Eregon (Benoit Daloze)" Date: 2021-12-06T13:25:59+00:00 Subject: [ruby-core:106513] [Ruby master Bug#18385] Refinement#import_methods(Enumerable) doesn't work Issue #18385 has been updated by Eregon (Benoit Daloze). zverok (Victor Shepelev) wrote in #note-2: > I didn't realize that `import_methods` is a make-believe feature, not really integrated with the interpreter/object model. Not sure what you mean by that, in my POV it is integrated and it has the effect to "copy" methods from a module to another module or to a refinement, so that refinements can apply as if they were defined there lexically. C extension-defined methods never supported refinements and likely never will (there is no lexical context for a call there). ---------------------------------------- Bug #18385: Refinement#import_methods(Enumerable) doesn't work https://bugs.ruby-lang.org/issues/18385#change-95173 * Author: zverok (Victor Shepelev) * Status: Closed * Priority: Normal * Assignee: shugo (Shugo Maeda) * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- Very simple to reproduce: ```ruby module M refine String do import_methods Enumerable end end ``` Leads to: `import_methods': Can't import method: Enumerable#drop (ArgumentError)` Which, grepping through code, seems to be raised [here](https://github.com/ruby/ruby/blob/master/eval.c#L1529) but I am not versed enough in Ruby internals to debug further. An attempt to `import_methods Comparable` leads to the same problem, BTW: `Can't import method: Comparable#between?` Am I missing something crucial about `import_method` behavior? -- https://bugs.ruby-lang.org/ Unsubscribe: