[#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:122045] [Ruby Bug#21316] Namespaces leak with permanent names
From:
"make_now_just (Hiroya Fujinami) via ruby-core" <ruby-core@...>
Date:
2025-05-13 11:20:22 UTC
List:
ruby-core #122045
Issue #21316 has been updated by make_now_just (Hiroya Fujinami).
I found an issue on `Marshal` and `Namespace` maybe related to this ticket.
When dumping an object defined in a namespace using Marshal, the result will vary depending on whether the namespace is held as a variable or constant, and whether `Marshal.dump` is performed inside or outside the namespace.
In other words, we have the following files:
`ns.rb`:
```ruby
class Foo
def dump_in_ns = Marshal.dump(self)
end
```
`main.rb`:
```ruby
ns = Namespace.new
ns.require("./ns.rb")
NS = Namespace.new
NS.require("./ns.rb")
puts "var / in ns"
begin
ns::Foo.new.dump
p :ok
rescue => ex
p :error
p ex
end
puts
puts "const / in ns"
begin
NS::Foo.new.dump
p :ok
rescue => ex
p :error
p ex
end
puts
puts "var / out ns"
begin
Marshal.dump(ns::Foo.new)
p :ok
rescue => ex
p :error
p ex
end
puts
puts "const / out ns"
begin
Marshal.dump(NS::Foo.new)
p :ok
rescue => ex
p :error
p ex
end
```
Then, the result is as follows:
```console
$ RUBY_NAMESPACE=1 ruby main.rb
var / in ns
:error
#<NoMethodError: undefined method 'dump' for an instance of #<Namespace:0x000000012018ed88>::Foo>
const / in ns
:error
#<NoMethodError: undefined method 'dump' for an instance of NS::Foo>
var / out ns
:error
#<TypeError: can't dump anonymous class #<Namespace:0x000000012018ed88>::Foo>
const / out ns
:ok
```
I'm not sure this issue is completely related to this ticket, but `Marshal.dump` should work in any case.
----------------------------------------
Bug #21316: Namespaces leak with permanent names
https://bugs.ruby-lang.org/issues/21316#change-113195
* Author: fxn (Xavier Noria)
* Status: Open
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Namespaces are not transparent for this program
```ruby
C = Class.new
C.name == 'C'
```
because under a non-main user namespace, the name of `C` has the namespace as a prefix.
--
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/