From: "rolf (Rolf T) via ruby-core" Date: 2024-11-18T09:12:36+00:00 Subject: [ruby-core:119956] [Ruby master Bug#20871] Including methods in Enumerable doesn't make them available in Array Issue #20871 has been updated by rolf (Rolf T). I managed to narrow it down a bit further. With the versions specified in https://github.com/rolftimmermans/ruby-20871/blob/main/Gemfile.lock: ```ruby % irb irb(main):001> require "active_support" irb(main):002> require "active_support/json/decoding" irb(main):003> require "active_support/core_ext/object/try" irb(main):004> irb(main):005* class Foo irb(main):006* include Enumerable irb(main):007> end irb(main):008> irb(main):009* module Ext irb(main):010* def foo irb(main):011* "foo" irb(main):012* end irb(main):013> end irb(main):014> irb(main):015> Enumerable.include(Ext) irb(main):016> => Enumerable irb(main):017> [].foo (irb):17:in `
': undefined method `foo' for an instance of Array (NoMethodError) [].foo ^^^^ from :187:in `loop' from /Users/rolftimmermans/.gem/ruby/3.3.6/gems/irb-1.14.1/exe/irb:9:in `' from /Users/rolftimmermans/.gem/ruby/3.3.6/bin/irb:25:in `load' from /Users/rolftimmermans/.gem/ruby/3.3.6/bin/irb:25:in `
' ``` ---------------------------------------- Bug #20871: Including methods in Enumerable doesn't make them available in Array https://bugs.ruby-lang.org/issues/20871#change-110687 * Author: sanderd17 (Sander Deryckere) * Status: Feedback * ruby -v: 3.3.6 * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- 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/