In article <3454c9680807010555i7bb90075h5b0665dcff69e0a9 / mail.gmail.com>,
  "Vladimir Sizikov" <vsizikov / gmail.com> writes:

> I'd like to double-check the Array#fill behavior and to figure out
> which is a proper/intended behavior
> and which is just a bug or not intended behavior. This is needed for
> the RubySpec project to
> provide better tests.
>
> The following simple code:
> [1, 2, 3].fill('a', 1, -3)
>
> Produces wildly different results on different MRI branches:
>
> * MRI 1.8.6pl114    #==> ArgumentError: argument too big.
> * MRI 1.8.6pl257    #==> Ignores the call, doesn't change anything.
> * MRI 1.8.7 branch #==> Ignores the call, doesn't change anything
> * MRI 1.8 branch    #==> Raises IndexError
> * MRI 1.9 branch    #==> Raises IndexError
>
> Maybe I starting to sound as a broken record, but was it really necessary
> to change the MRI 1.8.6 behavior at all? This is an incompatible change, and
> we end up with three different behaviors.

Interesting.  I test more.

What interesting is the inconsistency between
[1, 2, 3].fill('a', 1, -3) and
[1, 2, 3].fill('a', 1, -1).

I tested following script for several ruby versions.

  a1 = ([1, 2, 3].fill("a", 1, -1) rescue $!)
  a2 = ([1, 2, 3].fill("a", 1, -3) rescue $!)
  p [a1, a2]

ruby-1.6.0            [[1, 2, 3], [1, 2, 3]]
ruby-1.6.1            [[1, 2, 3], [1, 2, 3]]
ruby-1.6.2            [[1, 2, 3], [1, 2, 3]]
ruby-1.6.3            [[1, 2, 3], [1, 2, 3]]
ruby-1.6.4            [[1, 2, 3], [1, 2, 3]]
ruby-1.6.5            [[1, 2, 3], [1, 2, 3]]
ruby-1.6.6            [[1, 2, 3], [1, 2, 3]]
ruby-1.6.7            [[1, 2, 3], [1, 2, 3]]
ruby-1.6.8            [[1, 2, 3], [1, 2, 3]]
ruby-1.8.0            [[1, 2, 3], [1, 2, 3]]
ruby-1.8.1            [[1, 2, 3], [1, 2, 3]]
ruby-1.8.2            [[1, 2, 3], [1, 2, 3]]
ruby-1.8.3            [[1, 2, 3], [1, 2, 3]]
ruby-1.8.4            [[1, 2, 3], [1, 2, 3]]
ruby-1.8.5            [[1, 2, 3], [1, 2, 3]]
ruby-1.8.5p52         [[1, 2, 3], [1, 2, 3]]
ruby-1.8.5p113        [[1, 2, 3], #<ArgumentError: argument too big>]
ruby-1.8.5p115        [[1, 2, 3], #<ArgumentError: argument too big>]
ruby-1.8.5p231        [[1, 2, 3], #<ArgumentError: argument too big>]
ruby-1.8.5head(p231)  [[1, 2, 3], #<ArgumentError: argument too big>]
ruby-1.8.6(p0)        [[1, 2, 3], [1, 2, 3]]
ruby-1.8.6p36         [[1, 2, 3], [1, 2, 3]]
ruby-1.8.6p110        [[1, 2, 3], #<ArgumentError: argument too big>]
ruby-1.8.6p111        [[1, 2, 3], #<ArgumentError: argument too big>]
ruby-1.8.6p114        [[1, 2, 3], #<ArgumentError: argument too big>]
ruby-1.8.6p230        [[1, 2, 3], #<ArgumentError: argument too big>]
ruby-1.8.6head(p255)  [[1, 2, 3], [1, 2, 3]]
ruby-1.8.7(p0)        [[1, 2, 3], #<ArgumentError: argument too big>]
ruby-1.8.7p17         [[1, 2, 3], #<ArgumentError: argument too big>]
ruby-1.8.7p22         [[1, 2, 3], #<ArgumentError: argument too big>]
ruby-1.8.7head(p38)   [[1, 2, 3], [1, 2, 3]]
ruby-1.8(r17572)      [#<IndexError: negative length (-1)>, #<IndexError: negative length (-3)>]
ruby-1.9(r17749)      [#<IndexError: negative length (-1)>, #<IndexError: negative length (-3)>]

I think the inconsistency is just a bug of
ruby-1.8.5p113,
ruby-1.8.5p115,
ruby-1.8.5p231,
ruby-1.8.5p231,
ruby-1.8.6p110,
ruby-1.8.6p111,
ruby-1.8.6p114,
ruby-1.8.6p230,
ruby-1.8.7p0,
ruby-1.8.7p17 and
ruby-1.8.7p22.

ruby-1.8.5p52 or prior,
ruby-1.8.6p36 or prior,
ruby-1.8.6head,
ruby-1.8.7head,
ruby-1.8.7head,
ruby-1.8 and
ruby-1.9 has consistent behavior.

It seems
ruby-1.8.5p113,
ruby-1.8.6p110 and
ruby-1.8.7p0
introduces a bug.

The bug is fixed at
ruby-1.8.6head and
ruby-1.8.7head.

And the behavior is changed to exception at
ruby-1.8.8 and
ruby-1.9.

I think ruby-1.8.8 and ruby-1.9 decision can be changed.
-- 
Tanaka Akira