Bug #12345
closed
A module's private constants are given with `Module#constant(false)`
Added by sawa (Tsuyoshi Sawada) over 8 years ago.
Updated about 8 years ago.
Description
A module's private constants are given with Module#constant(false)
.
module A
X = 1
Y = 2
private_constant :Y
end
module B
Z = 3
W = 4
private_constant :W
end
A.constants # => [:X]
A.constants(false) # => [:X, :Y]
A.include B
A.constants # => [:X, :Z]
A.constants(false) # => [:X, :Y]
Besides this, I request a way to get the private constants of a module. I want:
A.private_constants # => [:Y]
A.private_constants(false) # => [:Y]
A.include B
A.private_constants # => [:Y, :W]
A.private_constants(false) # => [:Y]
- Tracker changed from Bug to Feature
Report upper half: is a bug, should be fixed.
- Tracker changed from Feature to Bug
- Backport set to 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
- Status changed from Open to Closed
Applied in changeset r55705.
variable.c: exclude private constants
- variable.c (rb_local_constants_i): exclude private constants
when excluding inherited constants too. [Bug #12345]
- Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: WONTFIX, 2.2: REQUIRED, 2.3: REQUIRED
- Backport changed from 2.1: WONTFIX, 2.2: REQUIRED, 2.3: REQUIRED to 2.1: WONTFIX, 2.2: REQUIRED, 2.3: DONE
ruby_2_3 r55868 merged revision(s) 55705.
- Backport changed from 2.1: WONTFIX, 2.2: REQUIRED, 2.3: DONE to 2.1: WONTFIX, 2.2: DONE, 2.3: DONE
ruby_2_2 r55930 merged revision(s) 55705.
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0