Issue #15877 has been reported by danielwaterworth (Daniel Waterworth).
----------------------------------------
Bug #15877: Incorrect constant lookup result in method on cloned class
https://bugs.ruby-lang.org/issues/15877
* Author: danielwaterworth (Daniel Waterworth)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: 2.6.3
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
This behavior seems wrong to me:
``` ruby
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
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>