ruby/ruby — pull request #368 by kachick (2013-07-28 06:39:05+00:00)
Title: Should Enumerator#initialize check frozen status?

ruby -v #=> ruby 2.0.0p247 (2013-06-27 revision 41674) [i686-linux]

Frozen Enumerator can modify positions.

```ruby
enum = [1, 2].to_enum.freeze
enum.next #=> 1
enum.rewind
enum.next #=> 1
```

But it can't replace receiver-object/block on following methods.

* Enumerator#initialize_copy
* Enumerator::Lazy#initialize_copy
* Enumerator::Lazy#initialize

```ruby
enum = [1, 2].to_enum.freeze
enum.send :initialize_copy, [1, 2] #=> RuntimeError: can't modify frozen Enumerator

lazy = [1, 2].to_enum.lazy.freeze
lazy.send :initialize_copy, [1, 2] #=> RuntimeError: can't modify frozen Enumerator::Lazy
lazy.send :initialize, [1, 2], &->{} #=> RuntimeError: can't modify frozen Enumerator::Lazy
```

Except Enumerator#initialize.

```ruby
enum = [1, 2].to_enum.freeze
enum.send :initialize, [3, 4] #=> warning: Enumerator.new without a block is deprecated; use Object#to_enum
#
enum.send :initialize, &->{} #=> #:each>
```

Is this a spec?