Project

General

Profile

Actions

Bug #19270

closed

Constants lookup and a singleton class issue

Added by andrykonchin (Andrew Konchin) over 2 years ago. Updated over 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:111453]

Description

I've noticed that a constant declared in a singleton class may be not visible on an object:

class A
  def c; C; end
end

a = A.new
klass = (class << a; self; end)
klass.const_set(:C, 1)
a.c
# (irb):2:in `c': uninitialized constant A::C (NameError)

I would expect that such constant is visible and accessible on an object. It is expected and intentional behaviour?


Related issues 1 (0 open1 closed)

Is duplicate of Ruby - Bug #19269: Constant lookup and #instance_evalClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0