Issue #16910 has been updated by Eregon (Benoit Daloze).


Actually I looked too fast, the correct location is
https://github.com/ruby/ruby/blob/b10c9d201222b144df7d63660d1c731af53c4ae2/class.c#L551-L559

So it's defined as a constant of itself (BasicObject) and not Object because Object is not defined yet it seems.
Those constants could probably be defined later though.

----------------------------------------
Misc #16910: BasicObject is resolved in BasicObject
https://bugs.ruby-lang.org/issues/16910#change-85781

* Author: fxn (Xavier Noria)
* Status: Closed
* Priority: Normal
----------------------------------------
I categorized this as Misc because I do not really know if this is a bug, or perhaps I miss some special rule in the resolution of relative constants.

Basically, I would expect

```ruby
class C < BasicObject
  BasicObject
end
```

or, even simpler,

```ruby
class BasicObject
  BasicObject
end
```


to raise `NameError`.

Reason would be that top-level constants are stored in `Object`, which is not among the ancestors in any of the two examples above.

Is my reasoning flawed or is it a bug? If flawed, which is the correct reasoning?



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>