Project

General

Profile

Bug #9740

super: no superclass method in Ruby 2.1.1

Added by wehu (Wei Hu) about 6 years ago. Updated almost 6 years ago.

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

Description

Below code will result into error:

super: no superclass method `foo' for #<Object:0x002b0430670fe8>

However, it can pass with Ruby 1.9 and I am not sure if it's feature changes or bug.

module A
  def foo
    puts "A"
  end
end

module B
  def foo
    puts "B"
    super
  end
  ub_meth = instance_method :foo
  define_method :foo do
    ub_meth.bind(self).call()
  end
end
a = Object.new
a.extend A
a.extend B
a.foo

Hi, Nakada,
Thanks for your fix @ r45565, but this still has problem. If we run my original example, it will result into:

B
B
B
t.rb:9: stack level too deep (SystemStackError)

I think the difference is: in the original example, I used define_method :foo to override the foo in Module B.


Related issues

Copied from Ruby master - Bug #9721: super: no superclass method in Ruby 2.1.1Closed04/10/2014Actions

Updated by wehu (Wei Hu) about 6 years ago

  • Copied from Bug #9721: super: no superclass method in Ruby 2.1.1 added

Updated by wehu (Wei Hu) about 6 years ago

sorry, looks like it's fixed @ r45585. We can close this one. Thanks a lot, Nobuyoshi. :)

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

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

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

I missed to include the reference in the commit log, but just in the test.

Updated by nagachika (Tomoyuki Chikanaga) about 6 years ago

The reference from r46005 was mistake. The changesets for this ticket were not backported yet. sorry for noise.

Updated by nagachika (Tomoyuki Chikanaga) almost 6 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED to 2.0.0: REQUIRED, 2.1: DONE

r45585 was already backported into ruby_2_1 branch at r46190 for #9721.

Updated by usa (Usaku NAKAMURA) almost 6 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: DONE to 2.0.0: DONE, 2.1: DONE

and also already backported into ruby_2_0_0 at r46157.

Also available in: Atom PDF