Project

General

Profile

Actions

Bug #13003

closed

About not Random instance of random: keyword ardument of Array#shuffle!

Added by metanest (Makoto Kishimoto) over 7 years ago. Updated about 7 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-dev:49892]

Description

Array#shuffle! の random: キーワード引数で、Randomのインスタンスでないような
任意のオブジェクトを渡してしまっていても、(最終的に)rb_random_ulong_limited 中の
rb_funcallv(obj, id_rand, 1, &lim) という呼び出しによりグローバルの rand が
呼び出されて、それっぽく動いてしまいます。

わざわざ random: キーワード引数で渡していながら、変なオブジェクトを渡してしまって
いる、というのは、ユーザのスクリプトのバグである可能性が高いと思うのですが、
それでもそれっぽく動いてしまうようになっている、というのは、そのように意図されて
いるものでしょうか?

Updated by aamine (Minero Aoki) about 7 years ago

  • Status changed from Open to Closed

This bug is already fixed, close.

Actions #3

Updated by nobu (Nobuyoshi Nakada) about 7 years ago

  • Tracker changed from Misc to Bug
  • Backport set to 2.2: REQUIRED, 2.3: REQUIRED, 2.4: REQUIRED
Actions #4

Updated by nobu (Nobuyoshi Nakada) about 7 years ago

  • Backport changed from 2.2: REQUIRED, 2.3: REQUIRED, 2.4: REQUIRED to 2.2: REQUIRED, 2.3: REQUIRED, 2.4: DONTNEED
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0