From: shannonskipper@... Date: 2020-05-07T16:12:40+00:00 Subject: [ruby-core:98189] [Ruby master Bug#16838] Enumerator::ArithmeticSequence missing allocator for #clone and #dup Issue #16838 has been reported by shan (Shannon Skipper). ---------------------------------------- Bug #16838: Enumerator::ArithmeticSequence missing allocator for #clone and #dup https://bugs.ruby-lang.org/issues/16838 * Author: shan (Shannon Skipper) * Status: Open * Priority: Normal * ruby -v: ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-darwin19] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- In Ruby 2.5, with an Enumerator: ``` ruby 1.step.clone #=> Enumerator ``` In Ruby 2.6, with an Enumerator::ArithmeticSequence: ``` ruby 1.step.clone #!> TypeError (allocator undefined for Enumerator::ArithmeticSequence) ``` I've gotten around it in 2.6 and 2.7 by checking if an enum is an ArithmeticSequence and reconstituting a new one if so: ``` ruby Range.new(enum.begin, enum.end, enum.exclude_end?) % enum.step ``` Instead of cloning: ```ruby enum.clone ``` I filed this as a bug rather than feature, since it seemed like a breaking change and I wasn't sure if it was intentional. Thank you! -- https://bugs.ruby-lang.org/ Unsubscribe: