Project

General

Profile

Actions

Bug #14958

closed

rand(endless_range) raises TypeError (no implicit conversion of Range into Integer)

Added by znz (Kazuhiro NISHIYAMA) almost 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
ruby -v:
ruby 2.6.0dev (2018-08-01 trunk 64154) [x86_64-linux]
[ruby-core:88261]

Description

I think TypeError message is a bit strange.

$ ruby -v
ruby 2.6.0dev (2018-08-01 trunk 64154) [x86_64-linux]
$ ruby -e 'p rand(1..1)'
1
$ ruby -e 'rand(1..)'
Traceback (most recent call last):
        1: from -e:1:in `<main>'
-e:1:in `rand': no implicit conversion of Range into Integer (TypeError)
$ ruby -e 'rand(nil..nil)'
Traceback (most recent call last):
        1: from -e:1:in `<main>'
-e:1:in `rand': no implicit conversion of Range into Integer (TypeError)
Actions #1

Updated by znz (Kazuhiro NISHIYAMA) almost 3 years ago

  • Description updated (diff)
Actions #2

Updated by nobu (Nobuyoshi Nakada) almost 3 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r64167.


random.c: endless range random

  • random.c (range_values): cannot determine the domain of an endless range. [ruby-core:88261] [Bug #14958]
Actions

Also available in: Atom PDF