
Issue #21316 has been updated by mame (Yusuke Endoh). This is definitely not ideal. `Class#name` could end up referring to a different constant. ```ruby # main.rb NS = Namespace.new NS.require "./sub" # sub.rb class C; end p C #=> expected: C #=> actual: NS::C ← This could refer to a different constant, which is problematic ``` @tagomoris suggested that `Class#name` should behave as follows: * If the current namespace is at the front, omit it and just return `"C"` * Otherwise, return something like `"#<Namespace: ...>::C"` ```ruby # main.rb NS = Namespace.new NS.require "./sub" p NS::C #=> #<Namespace: ...>::C # sub.rb class C; end p C #=> C ``` ---------------------------------------- Bug #21316: Namespaces leak with permanent names https://bugs.ruby-lang.org/issues/21316#change-113078 * Author: fxn (Xavier Noria) * Status: Open * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- Namespaces are not transparent for this program ```ruby C = Class.new C.name == 'C' ``` because under a non-main user namespace, the name of `C` has the namespace as a prefix. -- https://bugs.ruby-lang.org/