Bug #6864

bad value for range when using infinity with date or time

Added by slbug (Alex Grebennik) almost 6 years ago. Updated 5 months ago.

Target version:
ruby -v:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]


Steps to reproduce:

require 'date', 1.0/0.0) # works, # fails, 1.0/0.0) # fails, # fails

Tested on 1.9.3 and trunk. I think this is a bug, because there is no logic error. just ranges without one bound.


#1 [ruby-core:47161] Updated by slbug (Alex Grebennik) almost 6 years ago

And sometimes range behavior cant be understood -,

#2 [ruby-core:48793] Updated by mame (Yusuke Endoh) over 5 years ago

  • Status changed from Open to Assigned
  • Assignee set to tadf (tadayoshi funaba)
  • Target version set to 2.0.0

This is caused by the following behavior.

p <=> 1.0 #=> 1
p 1.0 <=> #=> nil

Funaba-san, what do you think?
It may be good to provide Date#coerce.

Yusuke Endoh

#3 [ruby-core:48795] Updated by tadf (tadayoshi funaba) over 5 years ago

this asymmetry is intentional.
i don't want to accept aNum + aDate.
Range's spec is variable.

#4 [ruby-core:48800] Updated by mame (Yusuke Endoh) over 5 years ago

  • Assignee changed from tadf (tadayoshi funaba) to matz (Yukihiro Matsumoto)
  • Target version changed from 2.0.0 to 2.6

I see, thank you. Then, addressing this issue requires
changing Range's spec, which is too heavy from this time.
I postpone this to next minor.

Yusuke Endoh

#5 Updated by naruse (Yui NARUSE) 5 months ago

  • Target version deleted (2.6)

Also available in: Atom PDF