From: "fxn (Xavier Noria)" Date: 2022-03-11T18:55:56+00:00 Subject: [ruby-core:107848] [Ruby master Feature#11547] remove top-level constant lookup Issue #11547 has been updated by fxn (Xavier Noria). I do not know which is the correct definition of `const_get`, Ruby core knows :). However, let me say that I have always thought about `const_get` as what happens during a _relative_ constant lookup. That is, in my mind, a relative constant lookup is basically: 1) Check the nesting + 2) `const_get` (conceptually, and includes `const_missing` if needed). Take for example: ```ruby Module.new.const_get(:String) # => String ``` You get `String` there, but it is not in the ancestors. Why? Because it is checking `Object` by hand, like the relative constant lookup algorithm does. I believe ```ruby String.const_get(:Hash) # => ``` has to be understood that way. ---------------------------------------- Feature #11547: remove top-level constant lookup https://bugs.ruby-lang.org/issues/11547#change-96788 * Author: gucki1 (Corin Langosch) * Status: Closed * Priority: Normal ---------------------------------------- If ruby cannot find a class in the specified scope it uses the top-level constant of the same name if it exists and emits a warning: ~~~ irb(main):006:0> class Auth; end => nil irb(main):007:0> class Twitter; end => nil irb(main):008:0> Twitter::Auth (irb):8: warning: toplevel constant Auth referenced by Twitter::Auth => Auth ~~~ In some cases this is not playing nicely with rails autoloading as can be seen here: https://github.com/rails/rails/issues/6931. Many more issues like this exist. Imo I don't see any reason why this fallback makes any sense. So I'd like to suggest to remove it completely or at least add an option to disable it. -- https://bugs.ruby-lang.org/ Unsubscribe: