Project

General

Profile

Actions

Bug #18799

closed

Refinement#import_methods vs attr_reader

Added by palkan (Vladimir Dementyev) almost 2 years ago. Updated over 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-darwin21]
[ruby-core:108660]

Description

Currently, it's not possible to import methods defined as attr_{reader, accessor,writer}:

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).

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0