[ruby-core:119971] [Ruby master Bug#20871] Including methods in Enumerable doesn't make them available in Array
From:
"jeremyevans0 (Jeremy Evans) via ruby-core" <ruby-core@...>
Date:
2024-11-20 01:12:37 UTC
List:
ruby-core #119971
Issue #20871 has been updated by jeremyevans0 (Jeremy Evans).
Backport changed from 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN to 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED
I had some extra time today, and I was able to find the cause, and once I found the cause, the fix was trivial: https://github.com/ruby/ruby/pull/12125
The root cause is a bug in the initial commit to allow Module#include to affect classes and modules that that have already included the receiver, commit:3556a834a2847e52162d1d3302d4c64390df1694 (which I wrote).
----------------------------------------
Bug #20871: Including methods in Enumerable doesn't make them available in Array
https://bugs.ruby-lang.org/issues/20871#change-110707
* Author: sanderd17 (Sander Deryckere)
* Status: Open
* ruby -v: 3.3.6
* Backport: 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED
----------------------------------------
Today, our CI pipeline started failing after the automatic update from v3.3.5 to v3.3.6.
After researching, it turned out that our core extensions to the `Array` class weren't loaded anymore.
The core-extensions code looks like this:
```ruby
module CoreExt
module Enumerable
def average
sum(&:to_f) / count if any?
end
# def ...
end
end
Enumerable.include CoreExt::Enumerable
```
After some debugging, it turned out that the `average` method was included in the `instance_methods` of `Enumerable`, but not in the `instance_methods` of `Array`.
Explicitly adding `Array.include CoreExt::Enumerable` fixes CI for our case.
The very strange thing is that it only happens on a release branch we are still maintaining. It doesn't happen on our main development branch (which also updated to v3.3.6 today). I have been unable to find the difference between both branches so far (they diverged a couple of months ago, but the base system is still regularly updated on both, and pretty similar).
After some digging around, I assume this commit is related to our issue: https://github.com/ruby/ruby/commit/edeb0319f7a95dfe3f9b895bcf32371dd8514726
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/