From: Magnus Holm <redmine@...>
Date: 2010-06-11T04:12:06+09:00
Subject: [ruby-core:30719] [Bug #3422] Object.const_get(:A, false) can access BasicObject::A

Bug #3422: Object.const_get(:A, false) can access BasicObject::A
http://redmine.ruby-lang.org/issues/show/3422

Author: Magnus Holm
Status: Open, Priority: Low
Category: core
ruby -v: ruby 1.9.2dev (2010-05-31 revision 28117) [x86_64-darwin10.3.0]

From the documentation of Module#const_get(sym, inherit=true):

  If the constant is not defined or is defined by the ancestors and inherit is false, NameError will be raised.

Yet, this works fine:

  BasicObject::A = 1
  Object.const_get(:A, false) # => 1

While I haven't tested it, I believe the attached patch should fix the issue.


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