Actions
Bug #21364
openConstant lookup in namespaces should be consistent
Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.5.0dev (2025-05-22T23:07:21Z rm-assertion 17e71c7a24) +PRISM [arm64-darwin24]
Description
This might be related to #21363, but I'm not sure.
I expect that a top level Bar
constant should have the same value as Object::Bar
. For example:
File.binwrite("ns.rb", <<-RUBY)
# namespace 3
Bar = 123
module M
def self.test
p Bar: Bar
p "Object::Bar": Object::Bar
end
TEST = -> {
p Bar: Bar
p "Object::Bar": Object::Bar
}
end
RUBY
Bar = 456
ns = Namespace.new
ns.load "./ns.rb"
ns::M.test
ns::M::TEST.call
The output is this:
RUBY_NAMESPACE=1 ./miniruby test.rb
./miniruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for known issues, etc.
{Bar: 123}
{"Object::Bar": 123}
{Bar: 123}
{"Object::Bar": 456}
But I expected this:
{Bar: 123}
{"Object::Bar": 123}
{Bar: 123}
{"Object::Bar": 123}
Constant lookups in methods seem to behave differently than in lambdas.
No data to display
Actions
Like0