Project

General

Profile

Actions

Feature #11547

closed

remove top-level constant lookup

Added by gucki1 (Corin Langosch) about 9 years ago. Updated over 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:<unknown>]

Description

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.


Related issues 3 (0 open3 closed)

Related to Ruby master - Bug #14148: Longstanding behavior regarding correspondence of toplevel with Object is surprisingClosedActions
Related to Ruby master - Bug #14407: defined? still returning true for top-level constant when referenced with scopeClosedActions
Related to Ruby master - Bug #18622: const_get still looks in Object, while lexical constant lookup no longer doesClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0