Project

General

Profile

Bug #11636

super in instance_eval in a method defined in a module is invoked with a wrong receiver

Added by shugo (Shugo Maeda) almost 4 years ago. Updated over 3 years ago.

Status:
Assigned
Priority:
Normal
Target version:
-
[ruby-core:71274]

Description

super in instance_eval in a method defined in a module is invoked with a wrong receiver:

class Foo
  def initialize
    @foo = :foo
  end

  def foo
    p [self, @foo]
  end
end

module M
  def foo
    x = Object.new
    x.instance_eval do
      super
    end
  end
end

class Bar < Foo
  include M
end

Bar.new.foo

The output should be [#Foo:..., :foo] or an exception.
Matz prefer the former (https://twitter.com/yukihiro_matz/status/659913844861464576).


Related issues

Related to Ruby master - Bug #2402: super in instance_evalClosedActions

History

#1

Updated by shugo (Shugo Maeda) almost 4 years ago

  • Related to Bug #2402: super in instance_eval added

Updated by ko1 (Koichi Sasada) over 3 years ago

  • Description updated (diff)

Updated by ko1 (Koichi Sasada) over 3 years ago

I don't touch this behavior because Ruby 2.3 preview 1 was already released.
I try it on Ruby 2.4.

Also available in: Atom PDF