jruby/jruby — pull request #1725 by alexdowad (2014-06-04 07:32:38+00:00)
Title: Make behavior of Array#eql? more closely match MRI

MRI's rb_ary_eql looks like this:

```
rb_ary_eql(VALUE ary1, VALUE ary2)
{
if (ary1 == ary2) return Qtrue;
if (!RB_TYPE_P(ary2, T_ARRAY)) return Qfalse;
if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse;
return rb_exec_recursive_paired(recursive_eql, ary1, ary2, ary2);
}
```

Notice the `RB_TYPE_P` check. This will be true for instances of `Array` or a subclass of `Array`.

However, JRuby's `Array#eql?` returns true for objects which are *not* Arrays, as long as they implement `#to_ary` and as long as all their members are `eql?` to the corresponding members in the receiver Array.

This is contrary to the intent of `#eql?` -- it is supposed to be a stricter version of `==` which checks not just value but also type.

This patch should bring the behavior of JRuby a little bit closer in line with MRI.