From: "shioyama (Chris Salzberg)" Date: 2022-10-18T07:53:45+00:00 Subject: [ruby-core:110378] [Ruby master Bug#19067] `private_constant` does not work at toplevel in wrapped module context Issue #19067 has been reported by shioyama (Chris Salzberg). ---------------------------------------- Bug #19067: `private_constant` does not work at toplevel in wrapped module context https://bugs.ruby-lang.org/issues/19067 * Author: shioyama (Chris Salzberg) * Status: Open * Priority: Normal * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- ```ruby #foo.rb module Foo end private_constant :Foo ``` ```ruby module MyModule; end load "./foo.rb", MyModule # undefined method `private_constant' for main:Object (NoMethodError) # # private_constant :Foo # ^^^^^^^^^^^^^^^^ # Did you mean? private_methods ``` However, this works: ```ruby module MyModule module Foo end private_constant :Foo end ``` `load` loads the code under the `wrap` module, so this seems like a bug to me. -- https://bugs.ruby-lang.org/ Unsubscribe: