From: fxn@... Date: 2017-01-01T15:07:52+00:00 Subject: [ruby-core:78929] [Ruby trunk Feature#11547] remove top-level constant lookup Issue #11547 has been updated by Xavier Noria. In particular this one http://guides.rubyonrails.org/autoloading_and_reloading_constants.html#when-constants-aren-t-missed. We'd love to base Rails autoloading on Kernel#autoload and have the exact same semantics, but that is not possible as of this writing (http://guides.rubyonrails.org/autoloading_and_reloading_constants.html#module-autoload-isn-t-involved). So, Rails does not attempt to emulate constant resolution at all (it does not have nesting information, it does not follow ancestor chains by design, etc.), you have to think autoloading as a feature with its own contract. You have to program against that contract. A change like this one is welcome though. Thanks. ---------------------------------------- Feature #11547: remove top-level constant lookup https://bugs.ruby-lang.org/issues/11547#change-62348 * Author: Corin Langosch * Status: Closed * Priority: Normal * Assignee: * Target version: ---------------------------------------- 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: