Feature #8184

Avoid the creation of meaningless ranges (nil, false, true)

Added by Pascal Hurni about 1 year ago.

[ruby-core:53822]
Status:Open
Priority:Normal
Assignee:-
Category:core
Target version:-

Description

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.

range_init_patch.diff Magnifier (807 Bytes) Pascal Hurni, 03/29/2013 11:16 PM

Also available in: Atom PDF