Project

General

Profile

Actions

Bug #21320

open

Namespaces leak with constant lookup

Added by fxn (Xavier Noria) 1 day ago. Updated about 11 hours ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:121955]

Description

The following program

X = :top

class C
  X = :super
end

class D < C
  p X
end

prints :super normally, and :top if running under a namespace.

Updated by Eregon (Benoit Daloze) about 11 hours ago

Full repro:

# Copy the description program to program.rb, e.g. $ xsel -b > program.rb
$ RUBY_NAMESPACE=1 ruby -ve 'puts "in main"; require "./program"; puts "in namespace"; Namespace.new.require "./program"' 
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
in main
:super
in namespace
:top
Actions

Also available in: Atom PDF

Like0
Like0Like0