[#122258] [Ruby Misc#21367] Remove link to ruby-doc.org from www.ruby-lang.org/en/documentation/ — "p8 (Petrik de Heus) via ruby-core" <ruby-core@...>
Issue #21367 has been reported by p8 (Petrik de Heus).
11 messages
2025/05/23
[ruby-core:122135] [Ruby Bug#21343] Namespace: singleton classes of root namespace leak between namespaces
From:
"byroot (Jean Boussier) via ruby-core" <ruby-core@...>
Date:
2025-05-16 07:34:43 UTC
List:
ruby-core #122135
Issue #21343 has been updated by byroot (Jean Boussier).
Seems adjacent to https://bugs.ruby-lang.org/issues/21330.
The `klass` field like the `flags` one isn't part of the `classext_t`, so it's not effectively namespaced.
----------------------------------------
Bug #21343: Namespace: singleton classes of root namespace leak between namespaces
https://bugs.ruby-lang.org/issues/21343#change-113287
* Author: jhawthorn (John Hawthorn)
* Status: Open
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Ruby classes all have singleton classes, those singleton classes have singleton classes, and so on with infinite nesting. Since we don't have infinite resources, we create these lazily.
Because of this, only a certain number of singleton classes exist in the root namespace. At a certain depth, mutable singleton classes end up shared between namespaces.
``` ruby
File.write("/tmp/ntest.rb", <<~'RUBY')
p String.singleton_class.singleton_class::Foo
String.singleton_class.singleton_class::Bar = 456
RUBY
String.singleton_class.singleton_class::Foo = 123
ns = Namespace.new
ns.require("/tmp/ntest.rb")
p String.singleton_class.singleton_class::Bar
```
```
RUBY_NAMESPACE=1 ruby nstest2.rb
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for known issues, etc.
123
456
```
--
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/