Project

General

Profile

Actions

Feature #16838

open

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

Added by shan (Shannon Skipper) over 4 years ago. Updated over 4 years ago.

Status:
Open
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!

Actions

Also available in: Atom PDF

Like0
Like0Like0