Project

General

Profile

Actions

Bug #2995

closed

TestHash#test_recursive_check fails

Added by shugo (Shugo Maeda) about 14 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.2dev (2010-03-23 trunk 27020) [i686-linux]
Backport:
[ruby-dev:40735]

Description

=begin
前田です。

以下の変更(r26961)で、TestHash#test_recursive_checkが失敗するようになっている
のですが、この変更は意図的でしょうか。

Wed Mar 17 16:25:53 2010 Nobuyoshi Nakada

     * hash.c (rb_hash_aset): allow recursive key.  [ruby-core:24648]

[ruby-core:24648]を見ると、

h={}
=> {}
h[:key] = h
=> {:key=>{....}}
h.hash
ArgumentError: recursive key for hash

のように値に自分自身を含むHashのhashメソッド呼び出しで例外が起こるという話で、

h[h] = :foo

のようにキーに自分自身を与えるというのとは違う話のように読めます。

また、test_recursive_checkにあるように

h = {}
h[h] = :foo

のようなコードを実行しても、h[h]で:fooは取得できません。
r26961はどういう意図の変更なのでしょうか。
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0