Project

General

Profile

Bug #13003

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

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

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

Description

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

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

Associated revisions

Revision 74ba0cfc
Added by nobu (Nobuyoshi Nakada) over 2 years ago

random.c: private rand

  • random.c (rb_random_ulong_limited): do not call private method rand. [ruby-dev:49892] [Misc #13003]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 56984
Added by nobu (Nobuyoshi Nakada) over 2 years ago

random.c: private rand

  • random.c (rb_random_ulong_limited): do not call private method rand. [ruby-dev:49892] [Misc #13003]

Revision 56984
Added by nobu (Nobuyoshi Nakada) over 2 years ago

random.c: private rand

  • random.c (rb_random_ulong_limited): do not call private method rand. [ruby-dev:49892] [Misc #13003]

Revision 56984
Added by nobu (Nobuyoshi Nakada) over 2 years ago

random.c: private rand

  • random.c (rb_random_ulong_limited): do not call private method rand. [ruby-dev:49892] [Misc #13003]

History

Updated by aamine (Minero Aoki) about 2 years ago

  • Status changed from Open to Closed

This bug is already fixed, close.

#3

Updated by nobu (Nobuyoshi Nakada) about 2 years ago

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

Updated by nobu (Nobuyoshi Nakada) about 2 years ago

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

Also available in: Atom PDF