< :前の番号
^ :番号順リスト
> :次の番号
P :前の記事(スレッド移動)
N :次の記事(スレッド移動)
|<:前のスレッド
>|:次のスレッド
^ :返事先
_:自分への返事
>:同じ返事先を持つ記事(前)
<:同じ返事先を持つ記事(後)
---:分割してスレッド表示、再表示
| :分割して(縦)スレッド表示、再表示
~ :スレッドのフレーム消去
.:インデックス
..:インデックスのインデックス
Issue #6838 has been reported by cpoirier (Chris Poirier).
----------------------------------------
Bug #6838: class_eval and instance_eval do not scope class names the same as direct code
https://bugs.ruby-lang.org/issues/6838
Author: cpoirier (Chris Poirier)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11]
class X
def self.f()
puts "::X"
end
end
class Y
class X
def self.f()
puts "Y::X"
end
end
def self.c()
X.f()
end
end
Y.class_eval do
def self.k()
X.f()
end
end
Y.c
Y.class_eval { X.f() }
Y.k
====
Y.c outputs "Y::X"
Y.class_eval { X.f() } outputs "::X"
Y.k also outputs "::X"
Similar behaviour happens with instance_eval:
====
class X
def f()
puts "::X"
end
end
class Y
class X
def f()
puts "Y::X"
end
end
def c()
X.new.f()
end
end
Y.new.c
Y.new.instance_eval { X.new.f() }
====
My expectation is that class_eval and instance_eval should map class names the same as code written directly in the class, as they do with function names.
--
http://bugs.ruby-lang.org/