Issue #3768 has been updated by Yukihiro Matsumoto.


Haven't I explained the reason?

The M is defined under the Object class.  The BasicObject does not inherit from Object.  So there's no reason M can be accessed from BasicObject, under the current behavior of constant accessing in Ruby.  If you want to "fix" this problem, how should I?  Making constants under Object can be accessed from everywhere? Or otherwise?

In any case, the "fix" would be huge change to the constant access system, and would introduce huge risk of incompatibility.

matz.
----------------------------------------
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 `<class:X>'
         from (irb):3
         from /home/trans/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'
=end



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