[#104004] [Ruby master Feature#17883] Load bundler/setup earlier to make `bundle exec ruby -r` respect Gemfile — mame@...
Issue #17883 has been reported by mame (Yusuke Endoh).
21 messages
2021/05/24
[ruby-core:104035] [Ruby master Bug#17887] Missed constant lookup after prepend
From:
eregontp@...
Date:
2021-05-25 13:45:53 UTC
List:
ruby-core #104035
Issue #17887 has been updated by Eregon (Benoit Daloze).
In the ancestors, `M` is before `A`, so this seems like a bug:
```
B.ancestors # => [B, M, A, Object, Kernel, BasicObject]
```
Also note that with `B.include M`, which reports the same ancestors, it works as expected:
```ruby
module M
FOO = 'm'
end
class A
FOO = 'a'
end
class B < A
def foo
FOO
end
end
b = B.new
p b.foo # => "a"
B.include M # instead of A.prepend M
p b.foo # => "m"
```
----------------------------------------
Bug #17887: Missed constant lookup after prepend
https://bugs.ruby-lang.org/issues/17887#change-92173
* Author: bjfish (Brandon Fish)
* Status: Open
* Priority: Normal
* ruby -v: 3.0.0
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
**Description**
The following shows that the constant lookup from B does not find the constant in the prepended M module. I would expect this lookup to behave like "B.include M" which does print the constant from module M.
**Example**
``` ruby
module M
FOO = 'm'
end
class A
FOO = 'a'
end
class B < A
def foo
FOO
end
end
b = B.new
p b.foo
A.prepend M
p b.foo
```
**Expected Result**
```
"a"
"m"
```
**Actual Result**
```
"a"
"a"
```
--
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>