The methods Array(), String(), Float(), Integer(), Hash(), and Rational() all return their argument when the argument is already an instance of the type in question. For example:

a = []
a.equal? Array(a) #=> true

However, the similar methods Pathname(), BigDecimal(), and Complex() do not do this:

p = Pathname.new('/tmp')
p.equal? Pathname(p) #=> false

I had the impression that the "Type()" methods were intended as "safe" coercion methods. That is, if no type conversion is required, then the system is left unchanged (and no new objects are created). The attached patch fixes the three methods mentioned above to adhere to this same invariant.

This issue still exists in the master branch, and while it isn't a bug, I think we should make the change. This change should cause no issues for BigDecimal and Complex, since those instances are already frozen. It could potentially cause issues for Pathname, since Pathname instances are not frozen by default, but considering Kernel#{Hash,Array,String} already return the receiver, it makes sense for Kernel#Pathname to do so as well.