CARVIEW |
Select Language
HTTP/2 200
x-amz-id-2: xRPODELk0KadTBqODdMv42SL8vnrKZLdeHd3mq7kN6uQYCC3Ic3bhpEU23DIihEI67FtlMJ9Cio=
x-amz-request-id: PEZE2NPTT946QJDS
last-modified: Thu, 22 May 2025 23:32:00 GMT
etag: "b442afac354631b885f188d33e05e19d"
x-amz-server-side-encryption: AES256
server: AmazonS3
content-encoding: gzip
via: 1.1 varnish, 1.1 varnish
content-type: text/plain; charset=utf-8
accept-ranges: bytes
age: 0
date: Sun, 27 Jul 2025 03:21:27 GMT
x-served-by: cache-tyo11949-TYO, cache-bom-vanm7210026-BOM
x-cache: MISS, MISS
x-cache-hits: 0, 0
x-timer: S1753586487.258476,VS0,VE309
vary: Accept-Encoding
content-length: 881
From: "tenderlovemaking (Aaron Patterson) via ruby-core"
Date: 2025-05-22T23:23:38+00:00
Subject: [ruby-core:122241] [Ruby Bug#21364] Constant lookup in namespaces should be consistent
Issue #21364 has been reported by tenderlovemaking (Aaron Patterson).
----------------------------------------
Bug #21364: Constant lookup in namespaces should be consistent
https://bugs.ruby-lang.org/issues/21364
* Author: tenderlovemaking (Aaron Patterson)
* Status: Open
* ruby -v: ruby 3.5.0dev (2025-05-22T23:07:21Z rm-assertion 17e71c7a24) +PRISM [arm64-darwin24]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
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:
```ruby
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.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/