Permalink
Browse files

Merge pull request #1709 from troessner/master

BasicObject includes itself in its list of constants.
  • Loading branch information...
2 parents d88af5b + 1435289 commit 9153ef626e0ec1608c8f72de6e63d3acfa6de249 @jc00ke jc00ke committed May 8, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −0 kernel/common/module19.rb
  2. +0 −1 spec/tags/19/ruby/core/basicobject/basicobject_tags.txt
View
4 kernel/common/module19.rb
@@ -114,6 +114,10 @@ def autoload(name, path)
def constants(all=undefined)
tbl = Rubinius::LookupTable.new
+ # When calling `constants` on "normal" classes the result does not include
+ # their own class name. BasicObject is a special case in this regard.
+ tbl[:BasicObject] = true if self == BasicObject
+
@constant_table.each do |name, val|
tbl[name] = true
end
View
1 spec/tags/19/ruby/core/basicobject/basicobject_tags.txt
@@ -1,3 +1,2 @@
fails:BasicObject raises NameError when referencing built-in constants
fails:BasicObject does not define built-in constants (according to defined?)
-fails:BasicObject includes itself in its list of constants

0 comments on commit 9153ef6

Please sign in to comment.