Project

General

Profile

Bug #13446

refinements with prepend for module has strange behavior

Added by mtsmfm (Fumiaki Matsushima) over 1 year ago. Updated over 1 year ago.

Status:
Assigned
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
[ruby-core:80748]

Description

using Module.new {
  refine Enumerable do
    alias :orig_sum :sum
  end
}

module Enumerable
  def sum(*args)
    orig_sum(*args)
  end
end

class GenericEnumerable
  include Enumerable

  def each
  end
end

# GenericEnumerable.new.sum # if we uncomment this line, `GenericEnumerable#sum` will work
Enumerable.prepend(Module.new) # if we comment out this line, `GenericEnumerable#sum` will work

p GenericEnumerable.new.sum # undefined method `orig_sum' for #<GenericEnumerable:0x0000000127c120 @values=[1, 2, 3]> (NoMethodError)

Is this intentional?

History

#1 [ruby-core:81696] Updated by nobu (Nobuyoshi Nakada) over 1 year ago

  • Assignee set to nobu (Nobuyoshi Nakada)
  • Status changed from Open to Assigned
  • Description updated (diff)

Also available in: Atom PDF