Project

General

Profile

Actions

Bug #9721

closed

super: no superclass method in Ruby 2.1.1

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

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

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

Related issues 1 (0 open1 closed)

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

Updated by nobu (Nobuyoshi Nakada) about 10 years ago

  • Description updated (diff)
  • Category set to core
  • Target version set to 2.2.0
  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: REQUIRED, 2.1: REQUIRED

Updated by nobu (Nobuyoshi Nakada) about 10 years ago

  • Description updated (diff)

Updated by nobu (Nobuyoshi Nakada) about 10 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Applied in changeset r45565.


proc.c: fix super in bound UnboundMethod

  • proc.c (rb_method_call_with_block, umethod_bind): call with
    IClass including the module for a module instance method.
    [ruby-core:61936] [Bug #9721]
  • vm_insnhelper.c (vm_search_super_method): allow bound
    UnboundMethod case.

Updated by wehu (Wei Hu) about 10 years ago

Hi, Nakada,
Thanks for your fix, 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.

Updated by wehu (Wei Hu) about 10 years ago

  • Copied to Bug #9740: super: no superclass method in Ruby 2.1.1 added

Updated by usa (Usaku NAKAMURA) almost 10 years ago

Backported r45564, r45565, r45584 and r45585 into ruby_2_0_0 at r46157.

Updated by usa (Usaku NAKAMURA) almost 10 years ago

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

Updated by nagachika (Tomoyuki Chikanaga) almost 10 years ago

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

r45179, r45564, r45565, r45584 and r45585 were backported into ruby_2_1 branch at r46190.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0