Bug #9533

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

Added by Takeshi Sasaki about 1 year ago. Updated about 1 year ago.

[ruby-dev:47988]
Status:Closed
Priority:Normal
Assignee:Masaki Matsushita
ruby -v:ruby 2.2.0dev (2014-02-19 trunk 45047) [x86_64-linux] Backport:1.9.3: DONTNEED, 2.0.0: DONTNEED, 2.1: DONE

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 で、挙動を変更した記載を確認できないため、バグと
判断しました。

hash_flatten_fix.patch Magnifier (2.04 KB) Takeshi Sasaki, 02/19/2014 03:25 PM

Associated revisions

Revision 45057
Added by glass about 1 year ago

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

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

Revision 45057
Added by glass about 1 year ago

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

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

Revision 45059
Added by glass about 1 year ago

  • hash.c (rb_hash_flatten): fix behavior of flatten(0).
    [Bug #9533]

  • test/ruby/test_array.rb: test for above. patch is from
    Takeshi Sasaki.

Revision 45059
Added by glass about 1 year ago

  • hash.c (rb_hash_flatten): fix behavior of flatten(0).
    [Bug #9533]

  • test/ruby/test_array.rb: test for above. patch is from
    Takeshi Sasaki.

History

#1 Updated by Masaki Matsushita about 1 year ago

  • Category set to core
  • Status changed from Open to Assigned
  • Assignee set to Masaki Matsushita
  • Target version set to current: 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

#2 Updated by Anonymous about 1 year 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).
    [Bug #9533]

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

#3 Updated by Yui NARUSE about 1 year 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.

Also available in: Atom PDF