natalie icon indicating copy to clipboard operation
natalie copied to clipboard

Scoping when reopening a toplevel constant

Open herwinw opened this issue 4 months ago • 1 comments

A piece of code because nobody will understand this title:

module Foo
  module Bar
    class ::Object
      Bar
    end
  end
end

This works fine in MRI, where it uses the Foo::Bar constant. In Natalie, it tries to look up ::Bar and fails.

This structure is used in the Nesting fixture in spec/core/module, which causes all the module specs in the nightly test to fail (we'd also need to implement Module.nesting, but we could just use a stub method).

Look up the exact rules for this, what happens when there is a toplevel Bar module as well? This must be documented somewhere.

herwinw avatar Oct 25 '24 17:10 herwinw