Project

General

Profile

Bug #9236

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

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

Status:
Closed
Priority:
Normal
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 (()).
=end


Related issues

Is duplicate of Ruby trunk - Bug #7842: An alias of a "prepend"ed method skips the original method when calling superClosed2013-02-13

Associated revisions

Revision b71956d1
Added by nobu (Nobuyoshi Nakada) over 4 years 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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 44175
Added by nobu (Nobuyoshi Nakada) over 4 years 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 nobu (Nobuyoshi Nakada) over 4 years 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 nobu (Nobuyoshi Nakada) over 4 years 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 nobu (Nobuyoshi Nakada) over 4 years 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 nobu (Nobuyoshi Nakada) over 4 years 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 f0f3821b
Added by nagachika (Tomoyuki Chikanaga) over 4 years ago

merge revision(s) 44175,44179: [Backport #9236]

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

* proc.c (mnew_from_me): achieve the original defined_class from
  prepended iclass, to fix inherited owner.

* proc.c (method_owner): return the defined class, but not the
  class which the method object is created from.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@44345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision aadf98f1
Added by nagachika (Tomoyuki Chikanaga) over 4 years ago

merge revision(s) 44198: [Backport #9236]

* proc.c (mnew_from_me): method by respond_to_missing? should be
  owned by the original class.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@44366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

History

#1 [ruby-dev:47847] Updated by matsuda (Akira Matsuda) over 4 years ago

  • Description updated (diff)

=begin
=end

#2 [ruby-dev:47848] Updated by nobu (Nobuyoshi Nakada) over 4 years ago

  • Description updated (diff)

#3 [ruby-dev:47849] Updated by matthewd (Matthew Draper) over 4 years ago

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

#4 Updated by nobu (Nobuyoshi Nakada) over 4 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.

#5 [ruby-dev:47850] Updated by nobu (Nobuyoshi Nakada) over 4 years ago

  • % Done changed from 0 to 100

#6 [ruby-dev:47851] Updated by matsuda (Akira Matsuda) over 4 years ago

Confirmed the fix. Thanks!

#7 [ruby-dev:47854] Updated by nobu (Nobuyoshi Nakada) over 4 years ago

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

#8 [ruby-dev:47859] Updated by nagachika (Tomoyuki Chikanaga) over 4 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.

Also available in: Atom PDF