Super return changed in 1.8.6

Hello,

The following snippet:

#!/usr/bin/ruby -w
require ‘date’
class MyDate < Date
def self.today
super
end
end
puts MyDate.today.class

end

prints out ‘MyDate’ with ruby 1.8.4 and 1.8.5, but ‘Date’ with 1.8.6

Is this a bug in 1.8.6, or the correction of a long lived bug in
versions before ?

Cheers,

Han H.

On 7/3/07, Han H. [email protected] wrote:

end
puts MyDate.today.class

end

prints out ‘MyDate’ with ruby 1.8.4 and 1.8.5, but ‘Date’ with 1.8.6

Is this a bug in 1.8.6, or the correction of a long lived bug in
versions before ?

It looks like perhaps the date library has changed in 1.8.6

http://svn.ruby-lang.org/repos/ruby/tags/v1_8_6/NEWS

" * date

  • Updated based on date2 4.0.3. "

I’ve not investigated further.

On 7/3/07, Gregory B. [email protected] wrote:

Indeed.
My question was whether this should be considered a bug: #today is
kind of a specialized version of #new, so I would expect the
implementation to be #new like, and return a MyDate.

Cheers,

Han H.

On 7/4/07, Han H. [email protected] wrote:

Indeed.
My question was whether this should be considered a bug: #today is
kind of a specialized version of #new, so I would expect the
implementation to be #new like, and return a MyDate.

That sounds to me like someone used Date.new instead of self.new in
class method somewhere. :slight_smile:

And yeah, I’d look at it as a bug too. As a workaround, you can
probably do a manual conversion…