Feature #19006
closedInconsistent behaviour of autoload in wrapped script
Description
Suppose I have two files, foo.rb and bar.rb:
and
I can require "foo" and access both Foo and Foo::Bar:
However, if I load foo under a wrap module with load:
... I'm now unable to access Foo::Bar anywhere, because whereas the constant is autoloaded from MyModule::Foo::Bar, it is required from the top-level as Foo::Bar:
This means that autoload is basically useless inside anything loaded with the wrap argument to load, because the file being autoloaded can't know in advance what the base namespace will be.
I would argue that it makes much more sense to apply the wrap module (top_wrapper) to any autoloaded file loaded when top_wrapper is set. In the example above, this would mean that accessing MyModule::Foo::Bar would work, since MyModule would apply when the autoload triggers to load foo/bar.