Project

General

Profile

Actions

Bug #10432

closed

wrong receiver of Binding from Method

Added by nobu (Nobuyoshi Nakada) over 9 years ago. Updated almost 9 years ago.

Status:
Closed
Target version:
-
ruby -v:
trunk
[ruby-core:65919]

Description

Methodオブジェクトからto_proc.bindingで作られたBindingのreceiverが、Methodオブジェクトの元になったオブジェクトではなく、Methodオブジェクトになっています。

class C
  def foo;end
end
o = C.new
m = o.method(:foo)
p m.receiver                    # #<C:0x007fcada074e58>
p m.to_proc.binding.receiver    # #<Method: C#foo>

2.0, 2.1ではBinding#receiverはありませんが、eval("self")で同様の結果になります。


Related issues 2 (0 open2 closed)

Related to Ruby master - Bug #10428: Segmentation fault when modifying local variables of binding obtained from the result of Method#to_procClosed10/26/2014Actions
Related to Ruby master - Bug #11163: Binding from Method#to_proc.binding cause BUGClosedko1 (Koichi Sasada)Actions

Updated by nobu (Nobuyoshi Nakada) over 9 years ago

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

Applied in changeset r48160.


proc.c: fix method proc binding receiver

  • proc.c (method_proc): the receiver of binding from method should
    be same as the receiver of the method.
    [ruby-core:65917] [Bug #10432]

Updated by nobu (Nobuyoshi Nakada) over 9 years ago

  • Related to Bug #10428: Segmentation fault when modifying local variables of binding obtained from the result of Method#to_proc added

Updated by usa (Usaku NAKAMURA) over 9 years ago

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

Backported into ruby_2_0_0 at r48633.
(元のレポートにもあるように2.0.0にはBinding#receiverがないため、テストを一部変更)

Updated by nagachika (Tomoyuki Chikanaga) about 9 years ago

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

Backported into ruby_2_1 at r49472.

Actions #5

Updated by ko1 (Koichi Sasada) almost 9 years ago

Methodオブジェクトからto_proc.bindingで作られたBindingのreceiverが、Methodオブジェクトの元になったオブジェクトではなく、Methodオブジェクトになっています。

元々、なんでこれじゃいけないんでしたっけ。
1.8 だと、b.eval('p self') がレシーバになっていたのかな。

Actions #6

Updated by nagachika (Tomoyuki Chikanaga) almost 9 years ago

  • Related to Bug #11163: Binding from Method#to_proc.binding cause BUG added
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0