Project

General

Profile

Feature #16838

Enumerator::ArithmeticSequence missing allocator for #clone and #dup

Added by shan (Shannon Skipper) 6 months ago. Updated 6 months ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:98189]

Description

In Ruby 2.5, with an Enumerator:

1.step.clone
#=> Enumerator

In Ruby 2.6, with an Enumerator::ArithmeticSequence:

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:

Range.new(enum.begin, enum.end, enum.exclude_end?) % enum.step

Instead of cloning:

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!

Also available in: Atom PDF