[ruby-dev:40474] [Bug #2787] nil.instance_eval pushes nil onto cref

Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[ruby-dev:40474] [Bug #2787] nil.instance_eval pushes nil onto cref

Dennis Ranke-2
Bug #2787: nil.instance_eval pushes nil onto cref
http://redmine.ruby-lang.org/issues/show/2787

起票者: Shugo Maeda
ステータス: Assigned, 優先度: Low
担当者: Yukihiro Matsumoto, カテゴリ: core
ruby -v: ruby 1.9.2dev (2010-02-18 trunk 26704) [i686-linux]

A singleton class definition of nil pushes NilClass onto cref.
It is reasonable because NilClass has nil as the only instance.
However, nil.instance_eval pushes nil onto cref, which means that method definitions are not permitted in that context.

  defiant:ruby$ ruby-trunk -ve 'class <<nil; def foo; puts "foo" end; end; nil.foo'
  ruby 1.9.2dev (2010-02-18 trunk 26704) [i686-linux]
  foo
  defiant:ruby$ ruby-trunk -ve 'nil.instance_eval {|i| def foo; puts "foo" end }; nil.foo'  
  ruby 1.9.2dev (2010-02-18 trunk 26704) [i686-linux]
  -e:1:in `block in <main>': no class/module to add method (TypeError)
  from -e:1:in `instance_eval'
  from -e:1:in `<main>'

The behavior is the same in Ruby 1.8.7.
Is it intended or a bug?


----------------------------------------
http://redmine.ruby-lang.org

Reply | Threaded
Open this post in threaded view
|

[ruby-dev:40475] [Bug #2787](Closed) nil.instance_eval pushes nil onto cref

Dennis Ranke-2
チケット #2787 が更新されました。 (by Shugo Maeda)

ステータス AssignedからClosedに変更

I'm sorry that I have sent this issue to the wrong ML.
I'll resubmit this issue later.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/2787

----------------------------------------
http://redmine.ruby-lang.org