From: "shugo (Shugo Maeda)" Date: 2022-05-25T06:50:22+00:00 Subject: [ruby-core:108692] [Ruby master Bug#18799] Refinement#import_methods vs attr_reader Issue #18799 has been updated by shugo (Shugo Maeda). As eregon stated, it's an intended imitation. It's possible to allow importing C methods without refinements activation. It may be helpful for attr_*, but not for define_method. ---------------------------------------- Bug #18799: Refinement#import_methods vs attr_reader https://bugs.ruby-lang.org/issues/18799#change-97737 * Author: palkan (Vladimir Dementyev) * Status: Open * Priority: Normal * ruby -v: ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-darwin21] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- Currently, it's not possible to import methods defined as attr_{reader, accessor,writer}: ```ruby module M attr_reader :fuu end module R refine Object do import_methods M end end #=> Can't import method which is not defined with Ruby code: M#fuu (ArgumentError) ``` Is that a known/intentional limitation or a bug? From the error message it might seem that this is a bug (since `attr_smth` is a Ruby code). -- https://bugs.ruby-lang.org/ Unsubscribe: