Bug #9236

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

Added by Akira Matsuda about 1 year ago. Updated about 1 year ago.

[ruby-dev:47846]
Status:Closed
Priority:Normal
Assignee:Koichi Sasada
ruby -v:ruby 2.1.0dev (2013-12-10 trunk 44126) [x86_64-darwin12.0] Backport:1.9.3: DONTNEED, 2.0.0: DONE

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 (()).
=end


Related issues

Duplicates Ruby trunk - Bug #7842: An alias of a "prepend"ed method skips the original metho... Closed 02/13/2013

Associated revisions

Revision 44175
Added by Nobuyoshi Nakada about 1 year ago

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.

Revision 44175
Added by Nobuyoshi Nakada about 1 year ago

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.

History

#1 Updated by Akira Matsuda about 1 year ago

  • Description updated (diff)

=begin
=end

#2 Updated by Nobuyoshi Nakada about 1 year ago

  • Description updated (diff)

#3 Updated by Matthew Draper about 1 year ago

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

#4 Updated by Nobuyoshi Nakada about 1 year 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.

#5 Updated by Nobuyoshi Nakada about 1 year ago

  • % Done changed from 0 to 100

#6 Updated by Akira Matsuda about 1 year ago

Confirmed the fix. Thanks!

#7 Updated by Nobuyoshi Nakada about 1 year ago

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

#8 Updated by Tomoyuki Chikanaga about 1 year 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.

Also available in: Atom PDF