From 4023ffa92f87c497659e737c41da6808df716a50 Mon Sep 17 00:00:00 2001 From: mrkn Date: Wed, 18 Aug 2010 09:42:36 +0000 Subject: [PATCH] * array.c (ary_make_shared), test/ruby/test_array.rb (test_permutation): always return the original array when it is shared. [ruby-dev:42067] [Bug #3708] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ array.c | 5 +---- test/ruby/test_array.rb | 3 +++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index ee07aae2aa..09983739f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Aug 18 18:36:32 2010 Kenta Murata + + * array.c (ary_make_shared), + test/ruby/test_array.rb (test_permutation): + always return the original array when it is shared. + [ruby-dev:42067] [Bug #3708] + Wed Aug 18 01:37:49 2010 NARUSE, Yui * regcomp.c: revert r26701; it introduces Bug #3681. diff --git a/array.c b/array.c index 51d3ad262a..ea4fe43ff0 100644 --- a/array.c +++ b/array.c @@ -409,10 +409,7 @@ static VALUE ary_make_shared(VALUE ary) { assert(!ARY_EMBED_P(ary)); - if (ARY_SHARED_P(ary)) { - return ARY_SHARED(ary); - } - else if (ARY_SHARED_ROOT_P(ary)) { + if (ARY_SHARED_P(ary) || ARY_SHARED_ROOT_P(ary)) { return ary; } else if (OBJ_FROZEN(ary)) { diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index e8edcc25e3..f2d723ffc9 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1549,6 +1549,9 @@ class TestArray < Test::Unit::TestCase a.permutation {|x| b << x; a.replace(@cls[9, 8, 7, 6]) } assert_equal(@cls[9, 8, 7, 6], a) assert_equal(@cls[1, 2, 3, 4].permutation.to_a, b) + + bug3708 = '[ruby-dev:42067]' + assert_equal(b, @cls[0, 1, 2, 3, 4][1, 4].permutation.to_a, bug3708) end def test_repeated_permutation