From: Jeremy Evans Date: 2011-07-04T09:38:18+09:00 Subject: [ruby-core:37763] [Ruby 1.9 - Bug #3768] Constant Lookup doesn't work in a subclass of BasicObject Issue #3768 has been updated by Jeremy Evans. If BasicObject.const_missing calls Object.const_get and the constant does not exist in Object, you've at best got a SystemStackError (I got SIGILL when I tried). I suppose this could work: class BasicObject def self.const_missing(name) ::Object.const_get(name) if ::Object.const_defined?(name) end end While safer, I do not advocate such an approach. For one, there's a TOCTOU race condition in threaded code if Object.remove_const is used. Personally, I don't see this as a major issue. There should be no need for this in BasicObject itself, and overriding const_missing in a BasicObject subclass is easy. ---------------------------------------- Bug #3768: Constant Lookup doesn't work in a subclass of BasicObject http://redmine.ruby-lang.org/issues/3768 Author: Thomas Sawyer Status: Rejected Priority: Normal Assignee: Yukihiro Matsumoto Category: lib Target version: ruby -v: 1.9.2-p0 =begin ruby-1.9.2-p0 > module M ruby-1.9.2-p0 ?> end => nil ruby-1.9.2-p0 > class X < BasicObject ruby-1.9.2-p0 ?> include M ruby-1.9.2-p0 ?> end NameError: uninitialized constant X::M from (irb):4:in `' from (irb):3 from /home/trans/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `
' =end -- http://redmine.ruby-lang.org