Actions
Bug #19067
closedModule methods not usable at toplevel under wrapped script
Description
#foo.rb
module Foo
end
private_constant :Foo
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:
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. If they cannot, then clarity is needed about what "being executed under" means in the documentation for load
.
Actions
Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0