lib/standard/collection: check the item can be compared in `Range#has`
authorJean Privat <jean@pryen.org>
Tue, 19 May 2015 14:54:49 +0000 (10:54 -0400)
committerJean Privat <jean@pryen.org>
Tue, 19 May 2015 23:42:26 +0000 (19:42 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

lib/standard/collection/range.nit

index 1ad0309..5ed0531 100644 (file)
@@ -30,7 +30,7 @@ class Range[E: Discrete]
        #     assert [1..10].has(5)
        #     assert [1..10].has(10)
        #     assert not [1..10[.has(10)
-       redef fun has(item) do return item >= first and item <= last
+       redef fun has(item) do return item isa Comparable and item >= first and item <= last
 
        #     assert [1..1].has_only(1)
        #     assert not [1..10].has_only(1)