Project

General

Profile

Actions

Bug #15877

closed

Incorrect constant lookup result in method on cloned class

Added by danielwaterworth (Daniel Waterworth) almost 5 years ago. Updated almost 5 years ago.

Status:
Closed
Target version:
-
[ruby-core:92849]

Description

This behavior seems wrong to me:

class Foo
  def test
    TEST
  end
end

Bar1 = Foo.clone
Bar2 = Foo.clone

class Bar1
  TEST = 'bar-1'
end

class Bar2
  TEST = 'bar-2'
end

# If these two lines are reordered, 'bar-2' is produced each time
p [:bar1_method, Bar1.new.test] # outputs 'bar-1' (correct)
p [:bar2_method, Bar2.new.test] # outputs 'bar-1' (incorrect)

p [:bar1_const, Bar1::TEST] # outputs 'bar-1' (correct)
p [:bar2_const, Bar2::TEST] # outputs 'bar-2' (correct)

Possibly related to #9603, #7107

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0