Project

General

Profile

Actions

Bug #9533

closed

ruby 2.1.0のHash#flattenが以前のバージョンと異なる挙動をする

Added by taksski (Takeshi Sasaki) over 10 years ago. Updated over 10 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 2.2.0dev (2014-02-19 trunk 45047) [x86_64-linux]
[ruby-dev:47988]

Description

ruby 2.1.0で、Hash#flattenに0以下の引数を与えた場合、ruby 2.0.0以前と
異なる結果を返します。例えば、以下のコード

h = {:a=>1, :b=>[2,3], :c=>4}
p h.flatten(-1)
p h.flatten(0)

をtest.rbとして実行すると、ruby 1.9.3では、

bash-4.2$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [i686-linux]
bash-4.2$ ruby test.rb
[:a, 1, :b, 2, 3, :c, 4]
[[:a, 1], [:b, [2, 3]], [:c, 4]]

となりますが、ruby 2.1.0では、

bash-4.2$ ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [i686-linux]
bash-4.2$ ruby test.rb
[:a, 1, :b, [2, 3], :c, 4]
[:a, 1, :b, [2, 3], :c, 4]

となります。ruby 2.1.0のドキュメント

http://docs.ruby-lang.org/ja/2.1.0/doc/index.html

および doc/NEWS-2.1.0 で、挙動を変更した記載を確認できないため、バグと
判断しました。


Files

hash_flatten_fix.patch (2.04 KB) hash_flatten_fix.patch taksski (Takeshi Sasaki), 02/19/2014 03:25 PM
Actions #1

Updated by Glass_saga (Masaki Matsushita) over 10 years ago

  • Category set to core
  • Status changed from Open to Assigned
  • Assignee set to Glass_saga (Masaki Matsushita)
  • Target version set to 2.2.0
  • ruby -v changed from ruby 2.1.0p0 (2013-12-25 revision 44422) [i686-linux] to ruby 2.2.0dev (2014-02-19 trunk 45047) [x86_64-linux]
  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN to 1.9.3: DONTNEED, 2.0.0: DONTNEED, 2.1: REQUIRED
Actions #2

Updated by Anonymous over 10 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

Applied in changeset r45057.


  • hash.c (rb_hash_flatten): fix behavior of flatten(-1).
    [ruby-dev:47988] [Bug #9533]

  • test/ruby/test_array.rb: test for above.

Updated by naruse (Yui NARUSE) over 10 years ago

  • Backport changed from 1.9.3: DONTNEED, 2.0.0: DONTNEED, 2.1: REQUIRED to 1.9.3: DONTNEED, 2.0.0: DONTNEED, 2.1: DONE

ruby_2_1 r45126 merged revision(s) 45057,45059.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0