Forum: Ruby-core [ruby-trunk - Feature #8184][Open] Avoid the creation of meaningless ranges (nil, false, true)

D51b68da10020e8eb90b6315a0664e81?d=identicon&s=25 phi (Pascal Hurni) (Guest)
on 2013-03-29 15:16
(Received via mailing list)
Issue #8184 has been reported by phi (Pascal Hurni).

----------------------------------------
Feature #8184: Avoid the creation of meaningless ranges (nil, false,
true)
https://bugs.ruby-lang.org/issues/8184

Author: phi (Pascal Hurni)
Status: Open
Priority: Normal
Assignee:
Category: core
Target version:


With the definition of <=> on Object on post 1.8, the range_init()
function no more throws "ArgumentError: bad value for range" when
creating these ranges:
  nil..nil
  false..false
  true..true

These kind of ranges are meaningless, the majority of methods on Range
do not work on them, like (nil..nil).include?(nil).

This feature request (with patch) re-introduces the 1.8 behaviour of
throwing ArgumentError when creating such ranges.
This topic is locked and can not be replied to.