Project

General

Profile

Actions

Bug #9626

closed

alias, prepend and super cause unexpected SystemStackError

Added by eagletmt (Kohei Suzuki) over 7 years ago. Updated over 7 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]
[ruby-core:61437]

Description

module M
  def foo
    super
  end
end

class C
  def foo
    'C#foo'
  end

  prepend M
  alias_method :orig_foo, :foo
  def foo
    orig_foo
  end
end

C.new.foo

I expect: M#foo -> C#foo -> C#orig_foo and get 'C#foo'
Actual: M#foo -> C#foo -> M#foo -> ... and get stack level too deep (SystemStackError)
If I swap the order of alias_method and prepend, it works as I expect.

I think it's closely related to #7842.

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

  • Description updated (diff)
  • Status changed from Open to Rejected

It differs from #7842, since you overwrites C#foo itself.
C#orig_foo is an alias of M#foo, but not of the former C#foo.

Actions

Also available in: Atom PDF