From: merch-redmine@... Date: 2020-05-18T22:44:58+00:00 Subject: [ruby-core:98430] [Ruby master Feature#16838] Enumerator::ArithmeticSequence missing allocator for #clone and #dup Issue #16838 has been updated by jeremyevans0 (Jeremy Evans). Backport deleted (2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN) ruby -v deleted (ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-darwin19]) Tracker changed from Bug to Feature `ArithmeticSequence.new` and `ArithmeticSequence.allocate` being undefined was definitely a deliberate change in commit:25a5227ab188b940d8bbc291bf4c9d62e5d63163. I'm not sure that breaking `clone` was expected. In general for frozen objects, I think `clone` without `freeze: false` should `return self`. However, that's currently how Ruby works. ---------------------------------------- Feature #16838: Enumerator::ArithmeticSequence missing allocator for #clone and #dup https://bugs.ruby-lang.org/issues/16838#change-85702 * Author: shan (Shannon Skipper) * Status: Open * Priority: Normal ---------------------------------------- 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: