Project

General

Profile

Actions

Bug #2402

closed

super in instance_eval

Added by shugo (Shugo Maeda) over 12 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 1.9.2dev (2009-11-24 trunk 25909) [i686-linux]
Backport:
[ruby-dev:39772]

Description

instance_evalのブロック内でsuperを呼ぶと、instance_evalで変更された
selfに対してsuperの呼び出しを行ってしまうようです。

defiant:build$ cat t.rb
class Foo
  def foo
    p self
  end
end

class Bar < Foo
  def foo
    x = Object.new
    x.instance_eval do
      super
    end
  end
end

Bar.new.foo
defiant:build$ ./ruby-trunk.1124 -v t.rb
ruby 1.9.2dev (2009-11-24 trunk 25909) [i686-linux]
#<Object:0x8590f6c>

Foo#fooが呼ばれるのにselfObjectという、ちょっとおかしなことになっています。
ちょっと自信がありませんが、一応パッチを添付します。


Files

super_in_instance_eval_fix.diff (2.03 KB) super_in_instance_eval_fix.diff shugo (Shugo Maeda), 11/25/2009 05:55 PM

Related issues 2 (0 open2 closed)

Related to Ruby master - Bug #3136: reuse of singleton method definition causes SEGVClosedko1 (Koichi Sasada)04/12/2010Actions
Related to Ruby master - Bug #11636: super in instance_eval in a method defined in a module is invoked with a wrong receiverClosedko1 (Koichi Sasada)Actions
Actions

Also available in: Atom PDF