From: "shioyama (Chris Salzberg)" Date: 2022-10-18T09:56:42+00:00 Subject: [ruby-core:110387] [Ruby master Bug#19067] Module methods not usable at toplevel under wrapped script Issue #19067 has been updated by shioyama (Chris Salzberg). > The documentation is unclear about what does "being executed under" mean. Without that definition, we cannot know if this is a bug. This is true. I am labelling it as a "bug" but it should be understood as "inconsistency". ---------------------------------------- Bug #19067: Module methods not usable at toplevel under wrapped script https://bugs.ruby-lang.org/issues/19067#change-99693 * 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. This applies to all methods on `Module`, which are usable inside a normal module definition but not usable when the module is the `wrap` argument to `load`. I think these should all be usable in this context. See: https://bugs.ruby-lang.org/issues/19024#note-23 -- https://bugs.ruby-lang.org/ Unsubscribe: