Project

General

Profile

Actions

Bug #9236

closed

include + include + alias_method + super behaviour inconsistency between 1.9 and 2.0

Added by matsuda (Akira Matsuda) over 10 years ago. Updated over 10 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.1.0dev (2013-12-10 trunk 44126) [x86_64-darwin12.0]
[ruby-dev:47846]

Description

=begin
The following code behaves differently under Ruby 1 and Ruby 2.

module Fun
def hello
orig_hello
end
end

module M1
def hello
p 'hello!'
end
end

module M2
def hello
super
end
end

class Foo
include M1
include M2

alias_method :orig_hello, :hello
include Fun

end

Foo.new.hello

% ruby -v fun.rb
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-darwin12.5.0]
"hello!"

% ruby -v fun.rb
ruby 2.1.0dev (2013-12-10 trunk 44126) [x86_64-darwin12.0]
fun.rb:3: stack level too deep (SystemStackError)

Let's see if this is an intended spec change or a bug.

(('#')) This issue was originally reported to ((<Rails Core ML by Gary Weaver|URL:https://groups.google.com/forum/#!topic/rubyonrails-core/z5Japo3oIzk>)).
=end


Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Bug #7842: An alias of a "prepend"ed method skips the original method when calling superClosednobu (Nobuyoshi Nakada)02/13/2013Actions

Updated by matsuda (Akira Matsuda) over 10 years ago

  • Description updated (diff)

=begin
=end

Updated by nobu (Nobuyoshi Nakada) over 10 years ago

  • Description updated (diff)

Updated by matthewd (Matthew Draper) over 10 years ago

git bisect says this changed in r36595, if it helps.

Actions #4

Updated by nobu (Nobuyoshi Nakada) over 10 years ago

  • Status changed from Open to Closed

This issue was solved with changeset r44175.
Yusuke, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


proc.c, vm_method.c: fix super and alias

  • proc.c (method_owner): return the class where alias is defined, not
    the class original method is defined.
  • vm_method.c (rb_method_entry_make, rb_alias): store the originally
    defined class in me. [Bug #7993] [Bug #7842] [Bug #9236]
  • vm_method.c (rb_method_entry_get_without_cache): cache included
    module but not iclass.

Updated by nobu (Nobuyoshi Nakada) over 10 years ago

  • % Done changed from 0 to 100

Updated by matsuda (Akira Matsuda) over 10 years ago

Confirmed the fix. Thanks!

Updated by nobu (Nobuyoshi Nakada) over 10 years ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: DONTNEED, 2.0.0: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) over 10 years ago

  • Backport changed from 1.9.3: DONTNEED, 2.0.0: REQUIRED to 1.9.3: DONTNEED, 2.0.0: DONE

r44175 and r44179 were backported to ruby_2_0_0 at r44345, and additionally r44198 was backported at 44366.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0